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

Forums / Developing with Sitefinity / Categorized search results?

Categorized search results?

11 posts, 0 answered
  1. adam
    adam avatar
    41 posts
    Registered:
    12 Jan 2009
    15 Feb 2010
    Link to this post
    How do I get my search results to be grouped by content tags when conducting a search?

    Thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Feb 2010
    Link to this post
    Hello adam,

    1. You need to create a custom provider to change the item url

    sample code

    public class CustomIndexProviderCustom : SomeModuleIndexProvider
    {
        public CustomIndexProviderCustom ()
        {
        }
     
        protected override Telerik.Framework.Search.IIndexerInfo GetIndexerInfo(string path, Telerik.Cms.Engine.IContent content, System.Globalization.CultureInfo cult)
        {
             //here change the result page url depending on your tag
     
            IList tags = manager.GetTags(content.ID);
            foreach (ITag tag in tags)
            {
                string taggedContentUrl = string.Format("~/SomePage.aspx?tag={0}", tag.TagName);
                return base.GetIndexerInfo(taggedContentUrl, content, cult);
                 
            }
            return base.GetIndexerInfo(path, content, cult);
     
        }
        
    }

    2. You need to change the ResultItem . You can add the item ID in the ResultItem snippet. Then get the content item object and associated tags as shown above. Then  you can separate the items. More information at  Search results are wrong

    Note that step 1 is not required, but it is good to have it.

    Sincerely yours,
    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. adam
    adam avatar
    41 posts
    Registered:
    12 Jan 2009
    15 Feb 2010
    Link to this post
    I think there is a misunderstanding.

    I have one main Search box that uses the Full Site index. On the search results page, I have the ContentSearchResults control that shows all the results. Currently, all my search results are jumbled together in one big list.

    I only want one search box for the whole site like it is currently and I also like my search results to be on one page, but I want them split into sections by content type, for example:

    Press Releases
    -Here are all the search hits on press releases-
    ...

    Products
    -Here are all the search hits on the product catalog-
    ...

    News
    -Here are all the search hits on the news items-
    ...

    Thanks!
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Feb 2010
    Link to this post
    Hello adam,

    My post describes how to split the SearchResult items by tags, categories or whatever you want. Please go through step two once again. You need to hack the search results control as described here and in the another post where I had a discussion.

    Regards,
    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.
  5. adam
    adam avatar
    41 posts
    Registered:
    12 Jan 2009
    15 Feb 2010
    Link to this post
    OK, regarding your original answer above:

    public class CustomIndexProviderCustom : SomeModuleIndexProvider

    Where does this code go and how is it referenced in the solution?

    //here change the result page url depending on your tag


    Why do I need to do anything to the URL? I just want to organize the list of search results, not do anything to the URLs.

    Thanks!
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Feb 2010
    Link to this post
    Hello adam,

    "Note that step 1 is not required, but it is good to have it."  I believe that this line from my previous post which is also bold make sense to you.

    Best wishes,
    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.
  7. adam
    adam avatar
    41 posts
    Registered:
    12 Jan 2009
    15 Feb 2010
    Link to this post
    OK, now I understand that you meant that modifying the URL is optional.

    However, I do not understand how to add the ID to the ResultItem Snippet. I added the ID field to the fieldsInfoProvider.xml and I see in the "Search results are wrong" post that you used the first 36 characters of the Snippet for ID. However, I am missing something because I do not see how the ID was put into the Snippet.

    Thanks!

  8. adam
    adam avatar
    41 posts
    Registered:
    12 Jan 2009
    16 Feb 2010
    Link to this post
    I ask the above question because when I set a breakpoint in SearchResult.ascx, I see that the Snippet string does not have any ID guid inside of it. How does the ID string get into Snippet in the first place? That's the code or process that I couldn't find in the other forum posts.

    Thanks!

  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Feb 2010
    Link to this post
    Hi adam,

    1. You need to include the content item ID to the SearchResult item. You can append the content item ID to the snippet. Then you can add the Hyperlink inside your template and change its NavigateUrl.

    2. You can modify ~/Sitefinity/ControlTemplates/Search/SearchResult.ascx

    •  edit ~/App_Data/Search/YOUR SEARCH NAME HERE/fieldsInfoProvider.xml to add blog id in the results snipper
       
    <?xml version="1.0" encoding="utf-8"?>
    <fields>
      <field name="ID" weight="1" indexAttribute="" filterTag="GUID" filterAttributes="" />
    <field name="keywords" weight="1" indexAttribute="content" filterTag="meta" filterAttributes="name:keywords;" />
      <field name="keywords" weight="1" indexAttribute="content" filterTag="meta" filterAttributes="name:keywords;" />
      <field name="description" weight="1" indexAttribute="content" filterTag="meta" filterAttributes="name:description;" />
      <field name="script" weight="-1" indexAttribute="" filterTag="script" filterAttributes="" />
      <field name="style" weight="-1" indexAttribute="" filterTag="style" filterAttributes="" />
    </fields>

    Restart the application once you add the id in fieldsInfoProvider.xml. The ID should exist in the snippet.

    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.
  10. adam
    adam avatar
    41 posts
    Registered:
    12 Jan 2009
    16 Feb 2010
    Link to this post
    Thanks for the clarification, but I did that but the ID still doesn't show in the Snippet string.

    Maybe the misunderstanding is that we are not trying to group by blog or blog id. We want to group by page parent. For example, our site page structure is like this:

    Home
        -Press Releases
        -Products
        -News
        -Etc

    and we want search results to be grouped the same way like this:

    Press releases
    -result item
    -result item

    Products
    -result item
    -result item
    ...

    Thanks for all the time you've spent trying to help us!
    Adam

  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Feb 2010
    Link to this post
    Hello adam,

    The IContent imte and ContentView control does not have property where the host page is set. You need to tag these items and then extract the tags from the content object.

    Kind regards,
    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.
Register for webinar
11 posts, 0 answered