Tridion custom search index handler: custom vs standard field for page url?

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) { //hardcoded for now, but will be read from publication metadata return "www.example.com"; } } } 
+6
source share
2 answers

You can save the url in the ContextText property. The Thies field is used to index the contents of the template data.

Tridion does not index common elements of a child publication.

Indexing is initiated by modifying an element (create, update, delete, localize and unlock). Or you can use the reindex tool to reindex ur. but there is no way to index common items in a child publication.

+5
source

I do not think that you can include the URL prefix in your search query as an indexed element. Because generic elements are not indexed, you are likely to index the page from the level of the website structure, which is never published.

When the group of structures moves, you will have to create an event handler that triggers the re-indexing of all child pages using the TOM.NET API protected method. This method is not part of the public API, so posting the code for this solution will probably declare me a non grata persona with R & D :)

Before reindexing something, you must save the source publication URL of the Group structure in the TcmEventArgs.ContextVariables property TcmEventArgs.ContextVariables that you can check if re-indexing is necessary.

+3
source

Source: https://habr.com/ru/post/922453/


All Articles