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

Forums / General Discussions / Search index starting point

Search index starting point

4 posts, 0 answered
  1. Steve
    Steve avatar
    31 posts
    Registered:
    03 May 2011
    20 Dec 2011
    Link to this post
    How can set up a search index that only indexes certain pages on my site? I want the search to start at a section page and search the content of any pages below it. The content on the pages consists of regular (not shared) content blocks.
  2. SUMO
    SUMO avatar
    5 posts
    Registered:
    14 Nov 2008
    21 Dec 2011
    Link to this post
    Out of the box, you can't.  (At least as far as 4.3)

    With a great deal of effort and some assistance from Telerik through a support ticket, we ended up writing a custom pipe provider to generate an index of the site below a particular parent page.

    Another 3.7 feature that was lost in 4.x

    Damian
  3. John Goerner
    John Goerner avatar
    1 posts
    Registered:
    11 Apr 2009
    21 Dec 2011
    Link to this post
    Thanks for the reply Damian. I can't believe they left this out of the "upgrade" to 4! Doesn't look like it's mentioned in the "roadmap" for future development either.
  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Aug 2017
    21 Dec 2011
    Link to this post
    Hello,

    To create a search index that covers only a selection of pages, you can register a custom PagesInboundPipe, where you can set the range to be passed to this pipe. Then you can register the pipe in the search index creation template and it will appear as an additional option. Please find below detailed instruction how you can set this up.
    1. Create a new class that inherits from the default PagesInboundPipe:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Sitefinity.Publishing.Pipes;
    using Telerik.Sitefinity.Modules.Pages;
    using Telerik.Sitefinity.Publishing;
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.Publishing.Model;
    using Telerik.Sitefinity.Pages.Model;
       
    namespace SitefinityWebApp
    {
        public class PageInboundPipeCustom:PageInboundPipe
        {
              
            public override void PushData(IList<Telerik.Sitefinity.Publishing.PublishingSystemEventInfo> items)
            {
                List<Telerik.Sitefinity.Publishing.PublishingSystemEventInfo> myItems = new List<Telerik.Sitefinity.Publishing.PublishingSystemEventInfo>();
     
                foreach (var item in items)
                {
                    PageNode node = null;
                    if (item.Item is WrapperObject && ((WrapperObject)item.Item).WrappedObject != null)
                        node = (PageNode)((WrapperObject)item.Item).WrappedObject;
                    else
                        node = ((PageNode)item.Item);
                    if (node.Page != null && node.Page.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
                    {
                        while (true)
                        {
                              
                            node = node.Parent;
       
                            if (node.Title == "GroupPage")
                            {//this will index only one page node with its children, don`t add items here for the pages that shouldn`t be indexed 
                                myItems.Add(item);
                                break;
                            }
       
                            if (node.Parent == null)
                            {
                                break;
                            }
                        }
                    }
                      
                }
                   
                base.PushData(myItems);
            }
        }
    }

    Notice how we're taking only the pages under the Group page "GroupPage" and then passing them to the base PushData() method, which will index only this selection of pages. You can customize this logic to include only the desired pages. Once you've build your custom InboundPipe for Pages, you'll neeed to register it in Global.asax, by subscribing to the Bootsrapper_Initialized event like this:
    void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
           {
               if (e.CommandName == "Bootstrapped")
               {
                   PublishingSystemFactory.RegisterPipe(PageInboundPipeCustom.PipeName, typeof(PageInboundPipeCustom));
                   var pipeSettings1 = PublishingSystemFactory.GetPipeSettings(PageInboundPipeCustom.PipeName);
                   PublishingSystemFactory.RegisterTemplatePipe("SearchItemTemplate", pipeSettings1);
               }
           }

    This will add a second Static HTML on pages option at the bottom of the search index creation template, which is the one using your custom pipe.
     All the best,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
4 posts, 0 answered