Search index starting point

Posted by Community Admin on 03-Aug-2018 14:46

Search index starting point

All Replies

Posted by Community Admin on 20-Dec-2011 00:00

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.

Posted by Community Admin on 21-Dec-2011 00:00

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

Posted by Community Admin on 21-Dec-2011 00:00

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.

Posted by Community Admin on 21-Dec-2011 00:00

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

This thread is closed