I played with custom search indexing handlers for SDL Tridion 2011 (GA). Something works for me, using very useful information provided by Arjen , however I am not sure that my execution is the best option.
The requirement is to be able to search for pages in the CMS by URL (for example, www.example.com/news/index.html). For this, I have created a class using the ISearchIndexingHandler interface (code below). I am indexing the url in the ContentText field of the element, however I'm not sure if this usually contains something else for the page (I think the page contains only metadata, so this should be OK). The advantage of using this in a custom field is that I can simply enter the URL into the search field without using <url> IN <fieldname> or something like that.
So my question is, is there any reason not to use a ContentText for Pages, and is there any advantage to using a custom field? In addition, bonus points are sent to everyone who has good ideas on how to handle BluePrinting (if I create a page in the parent publication, I want the local URLs to also be indexed in child publications), and when the path is changed structure groups (I think I can somehow call the re-index of the elements of the child pages from my indexing handler).
The code:
using System; using Tridion.ContentManager.Search; using Tridion.ContentManager.Search.Indexing.Handling; using Tridion.ContentManager.Search.Indexing.Service; using Tridion.ContentManager.Search.Indexing; using Tridion.ContentManager.Search.Fields; namespace ExampleSearchIndexHandler { public class PageUrlHandler : ISearchIndexingHandler { public void Configure(SearchIndexingHandlerSettings settings) { } public void ExtractIndexFields(IdentifiableObjectData subjectData, Item item, CoreServiceProxy serviceProxy) { PageData data = subjectData as PageData; if (data != null) { PublishLocationInfo info = data.LocationInfo as PublishLocationInfo; string url = GetUrlPrefix(data) + info.PublishLocationUrl; item.ContentText = url; } } private string GetUrlPrefix(PageData page) {
source share