+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / News Item Search Index Problem.

News Item Search Index Problem.

3 posts, 0 answered
  1. Renee
    Renee avatar
    2 posts
    Registered:
    24 Aug 2010
    01 Sep 2010
    Link to this post
    I cannot get the search function on our site to narrow down. I've been reading through the forums and playing around with it, and it's not helping.

    We have a few sections of the site that are supposed to have very narrow search areas, which search news items in specific categories. One of these sections is the Bookstore.

    Now, if I set the main Bookstore page as the results page, I get a bunch of other news items--in categories that aren't listed anywhere on the Bookstore page or any of the subpages--mixed in when I search, with their URLs listing them as part of the Bookstore.

    If I try to instead narrow the search by choosing the bottom-level subpages for all of the different categories in the bookstore as the results page and reindex, it INCREASES the number of indexed pages, and throws up some articles as duplicates with different URLs that reflect all of the different subpages.

    Is there some hidden way to just say to SiteFinity that you want an index to just index news items in a specific news category?

    (Note that I didn't build this site, and know nothing about ASP.NET. I'm learning as I go along, since I only theoretically know HTML, CSS, and some open source CMSes.)
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Sep 2010
    Link to this post
    Hello Renee,

    By default you cannot set which items to be indexed. The NewsIndex gets all published IContent items from a given provider and the crawler gets all data. Then in our provider we build the news url. You can tweak the built-in news provider and implement filtering based on category or any other specific parameters you would like to use.

    here is a sample code that will add only items from a certain category to the index

    public class NewsIndexProviderCustom : Telerik.News.NewsIndexProvider
    {
        public NewsIndexProviderCustom()
        {
            //
            // TODO: Add constructor logic here
            //
        }
     
        public override Telerik.Framework.Search.IIndexerInfo[] GetContentToIndex()
        {
            //return base.GetContentToIndex();
     
            if (this.retrievalMethod != RetrievalMethod.Direct)
                return new IIndexerInfo[0];
     
            if (this.manager == null)
                throw new InvalidOperationException("Manager is null");
     
            IMetaSearchInfo[] filter = this.manager.GetFilter(this.FilterExpression);
     
            if (ContentManager.Providers[DataProviderName].MetaKeys.ContainsKey("Category"))
            {
                List<IMetaSearchInfo> newFilter = new List<IMetaSearchInfo>(filter);
                MetaSearchInfo searchInfo = new MetaSearchInfo(MetaValueTypes.DateTime, "Publication_Date", "SomeName", SearchCondition.Equal);
                newFilter.Add(searchInfo);
                filter = newFilter.ToArray();
            }
            IList itemsList = this.manager.GetContent(0, 0, String.Empty, ContentStatus.Published, this.ParentIDs, filter);
     
            List<IContent> lst = new List<IContent>();
            foreach (IContent cnt in itemsList)
            {
                if (!lst.Contains(cnt))
                    lst.Add(cnt);
            }
     
            List<IIndexerInfo> data = new List<IIndexerInfo>(lst.Count);
            foreach (IContent content in lst)
            {
                if (content != null)
                {
                    if (this.manager.Provider.AllowLocalization)
                    {
                        foreach (string lng in content.Languages)
                        {
                            CultureInfo cult = CultureInfo.GetCultureInfo(lng);
                            string path = this.GetItemUrl(content, this.baseUrl, cult);
                            data.Add(this.GetIndexerInfo(path, content, cult));
                        }
                    }
                    else
                    {
                        string path = this.GetItemUrl(content, this.baseUrl, null);
                        data.Add(this.GetIndexerInfo(path, content));
                    }
                }
            }
            return data.ToArray();
        }
        
    }

    You can register the provider in your web.config

    <search defaultProvider="Search">
            <providers>
                <clear/>
                <add name="Search" type="Telerik.Search.Data.DefaultProvider, Telerik.Search.Data" connectionStringName="DefaultConnection" useCompoundIndexFile="true"/>
            </providers>
            <indexClients>
                ....      
                                       ....
                <add name="NewsIndexProviderCustom" type="NewsIndexProviderCustom, App_Code" settingsControl="Telerik.News.WebControls.Search.NewsIndexSettingsControl, Telerik.News" viewSettingsControl="Telerik.News.WebControls.Search.NewsIndexViewControl, Telerik.News" description="Provides not automatic indexing services for News"/>
                  ......
            </indexClients>


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. PPT
    PPT avatar
    4 posts
    Registered:
    24 Jan 2012
    02 Jul 2012
    Link to this post
    How can this be done in SF 4.4?


Register for webinar
3 posts, 0 answered