Search index starting point
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.
Out of the box, you can't. (At least as far as 4.3)
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.
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);
"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);