我正在研究 SDL Tridion 2011 (GA) 的自定义搜索索引处理程序。我得到了一些工作,使用Arjen 提供的非常有用的信息 http://80000ft.blogspot.nl/2012/08/search-indexing-handlers.html,但是我不确定我的执行是否是最佳选择。
要求是能够通过 url 在 CMS 中搜索页面(例如 www.example.com/news/index.html)。为了做到这一点,我使用创建了一个类ISearchIndexingHandler
接口(代码如下)。我正在项目的 ContentText 字段中索引 url,但是我不确定这通常是否会包含页面的其他内容(我认为页面只有元数据,所以这应该没问题)。与自定义字段相比,使用此字段的优点是我可以简单地在搜索框中键入 url,而无需使用 IN 或类似的内容。
所以我的问题是,是否有任何理由不使用 ContentText for Pages,以及使用自定义字段有什么优势吗?此外,任何对如何处理 BluePrinting 有好主意的人都会获得奖励分数(如果我在父出版物中创建页面,我希望本地 URL 也能在子出版物中建立索引),以及更改结构组路径的情况(我想我可以以某种方式从索引处理程序中触发子页面项目的重新索引)。
代码:
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";
}
}
}
您可以将 url 存储在 ContextText 属性中。 Thies 字段用于索引模板内容数据。
Tridion 不会为子出版物的共享项目建立索引。
索引在项目修改(创建、更新、删除、本地化和取消本地化)时触发。
或者您可以使用重新索引工具来重新索引您的项目。但无法为子出版物中的共享项目建立索引。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)