Set start page for search index?

Posted by Community Admin on 04-Aug-2018 18:10

Set start page for search index?

All Replies

Posted by Community Admin on 01-Oct-2012 00:00

How can I set a start page for a search index, like I could in 3.7? I want to search page content in a particular folder. There appears to be no way to do this when indexing static html content.

Posted by Community Admin on 04-Oct-2012 00:00

Hi,

There is no way to designate a start page from where the search will start, by default it indexes all pages.
This can be done by cusomizing the search pipe that pulls pages content to limit the search for only one under certain group page or parent page.

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);
           
       

To have multiple custom pipes indexing under different group pages register them like:
protected void Application_Start(object sender, EventArgs e)
        
            Bootstrapper.Initialized += Bootstrapper_Initialized;
        
  
        void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
        
if (e.CommandName == "Bootstrapped")
            
  
                // UnregisterCustomPipes();
//you can unregister pipes if you want to make updates to a pipe installaiton or the pipe must be registered again
  
                PipeFactory.UnregisterPipe("AirPipe");
                PipeFactory.UnregisterPipe("PagePipe");
                PipeFactory.UnregisterPipe("PagePipe1");
   
//installing pipes
                PublishingSystemFactory.RegisterPipe("AirPipe", typeof(AirPipe));
                var pipeSettings1 = PublishingSystemFactory.CreateDefaultPagePipeSettings("AirPipe");
                pipeSettings1.UIName = "AirPipe";
                PublishingSystemFactory.RegisterPipeSettings("AirPipe", pipeSettings1);
   
                var pipeDefinitions = PublishingSystemFactory.CreateDefaultPagePipeDefinitions();
                PublishingSystemFactory.RegisterPipeDefinitions("AirPipe", pipeDefinitions);
   
                var pipeMappings = PublishingSystemFactory.GetDefaultInboundMappingForPages();
                PublishingSystemFactory.RegisterPipeMappings("AirPipe", true, pipeMappings);
   
                pipeSettings1 = PublishingSystemFactory.GetPipeSettings("AirPipe");
                PublishingSystemFactory.RegisterTemplatePipe("SearchItemTemplate", pipeSettings1);
 //installing multiple instances of one Type of pipe is done like this:
                // another pipe
                PublishingSystemFactory.RegisterPipe("PagePipe", typeof(SolutionsPipe));
                var pipeSettings2 = PublishingSystemFactory.CreateDefaultPagePipeSettings("PagePipe");
                pipeSettings2.UIName = "SolutionsPipe";
   
                PublishingSystemFactory.RegisterPipeSettings("PagePipe", pipeSettings2);
   
                var pipeDefinitions2 = PublishingSystemFactory.CreateDefaultPagePipeDefinitions();
                PublishingSystemFactory.RegisterPipeDefinitions("PagePipe", pipeDefinitions2);
   
                var pipeMappings2 = PublishingSystemFactory.GetDefaultInboundMappingForPages();
                PublishingSystemFactory.RegisterPipeMappings("PagePipe", true, pipeMappings2);
   
                pipeSettings2 = PublishingSystemFactory.GetPipeSettings("PagePipe");
                PublishingSystemFactory.RegisterTemplatePipe("SearchItemTemplate", pipeSettings2);
   
                //3-rd
                PublishingSystemFactory.RegisterPipe("PagePipe1", typeof(VitavoxPipe));
                var pipeSettings3 = PublishingSystemFactory.CreateDefaultPagePipeSettings("PagePipe1");
                pipeSettings3.UIName = "VitavoxPipe";
   
                PublishingSystemFactory.RegisterPipeSettings("PagePipe1", pipeSettings3);
   
                var pipeDefinitions3 = PublishingSystemFactory.CreateDefaultPagePipeDefinitions();
                PublishingSystemFactory.RegisterPipeDefinitions("PagePipe1", pipeDefinitions3);
   
                var pipeMappings3 = PublishingSystemFactory.GetDefaultInboundMappingForPages();
                PublishingSystemFactory.RegisterPipeMappings("PagePipe1", true, pipeMappings3);
   
                pipeSettings3 = PublishingSystemFactory.GetPipeSettings("PagePipe1");
                PublishingSystemFactory.RegisterTemplatePipe("SearchItemTemplate", pipeSettings3);
   
 


Regards,
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

Posted by Community Admin on 04-Oct-2012 00:00

Thank you for the extremely detailed response! I think this may do the trick.

Posted by Community Admin on 15-Jan-2014 00:00

I am trying out this method, however it is not working for me at all. It compiles, and i get no errors. However, It just doesn't do anything....
am i missing something?


I Made a thread about this myself, But still no reply. This is a task i need before my companies website can go live. any help would be appreciated. My source code is listed in the link..

Posted by Community Admin on 20-Jan-2014 00:00

Hi,

Make sure that after adding the required classes and register the custom pipe for pages to have a page titled GroupPage (as per the example provided before)

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

After registering the custom pipe recreate the search index on the site, the newly created search index will be using the new custom pipe for pages.

Regards,
Stanislav Velikov
Telerik
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

Posted by Community Admin on 20-Jan-2014 00:00

are the node.Title's the same as the page name in the pages menu?
if i have a page called "About" the node should be "About" aswell right, But what if I have a space in the title. 
"About Us" ,

how will that be formatted as a node?

will it be "About-Us", "About Us", "AboutUs", "About.Us"  ?

Posted by Community Admin on 23-Jan-2014 00:00

Hi,

Yes the call to node.Title

(node.Title == "About us"
refers to the name of the page as saved in the page properties, here is a screenshot.

Regards,
Stanislav Velikov
Telerik
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

Posted by Community Admin on 29-Jan-2014 00:00

Daniel, just a though...

While it is detailed in the code sample it is worth re-iterating that registering the custom pipe MUST come in the Initialized event (and not the Initializing event which obviously occurs first - the correct event, Initialized, fires after the Search and Publishing modules are initialised/activated and having these modules operational is a pre-requisite to the correct lifecycle or operation of ones custom pipes when said pipes interact with the "SearchItemTemplate" and/or "PublishingItemTemplate" I believe?

This thread is closed