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

Forums / Developing with Sitefinity / How to associate categories with search indexes

How to associate categories with search indexes

4 posts, 0 answered
  1. Roland
    Roland avatar
    45 posts
    Registered:
    23 Feb 2009
    29 Apr 2009
    Link to this post
    I created my own IndexingProvider but now I want to be able to associate the indexes to categories. For example I created a "NewsIndexItem" and I want to associate that with a certain category in News like "Classified, Politics, Current Events". How will I be able to do that?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Apr 2009
    Link to this post
    Hello Roland,

    Generally GenericContent based modules have metakey Category which is set in the web.config. Category metakey has property searchable="True" which means that all items that has been categorized are searchable.

    You could try to create a collection of categories and add them to a drop down then concatenate the text you have entered in the searchbox to the value of the dropdown. A good sample of this approach is our Forum search

    If your approach is different, let us know.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Roland
    Roland avatar
    45 posts
    Registered:
    23 Feb 2009
    30 Apr 2009
    Link to this post
    Hi Ivan,

    Thanks for the suggestion its really a good one however what I really need is I can associate the category with searchindexes dynamically. Without having to manually choose from the categories. Is there a way where I can add checkboxlist to the "settingscontrol" of my search searchindex where it lists the categories which I will choose to associate with my searchindex?or what about the add/edit of category where I will include a dropdownlist/checkboxlist of searchindexes so i can choose what indexes the category will be associated?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 May 2009
    Link to this post
    Hi Roland,

    In your CustomIndexProvider you can add filters to search into your module categories.

    Sample code:

     public IIndexerInfo[] GetContentToIndex() 
            { 
                var list = new List<IIndexerInfo>(); 
     
                // get current events 
                var mgr = new ContentManager("Generic_Content"); 
                var filters = new IMetaSearchInfo[1]; 
                filters[0] = new MetaSearchInfo(MetaValueTypes.ShortText, "Category",SearchCondition.Equal, JoinType.And) 

    Instead of checkbox  you should better have a bounded drop down. When you create a new categories they will be added to the collection. Checkboxes is a good solution if you have hardcoded categories.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
4 posts, 0 answered