Wil*_*ill 6 search tridion tridion-2011
我正在玩SDL Tridion 2011(GA)的自定义搜索索引处理程序.我使用Arjen提供的非常有用的信息得到了一些工作,但是我不确定我的执行是否是最好的选择.
要求是能够通过URL搜索CMS中的页面(例如www.example.com/news/index.html).为了做到这一点,我使用ISearchIndexingHandler接口创建了一个类(下面的代码).我正在索引项目的ContentText字段中的url,但是我不确定这通常是否包含页面的其他内容(我认为页面只有元数据,所以这应该没问题).在自定义字段上使用它的优点是我只需在搜索框中键入url,而无需使用<url> IN <fieldname>或类似的东西.
所以我的问题是,有没有理由不使用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";
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
您可以将URL存储在ContextText属性中.Thies字段用于索引模板内容数据.
Tridion不会索引子出版物的共享项目.
在项目修改(创建,更新,删除,本地化和非本地化)上触发索引.或者您可以使用重建索引工具重新索引您的项目.但是没有办法在子出版物中索引共享项目.
| 归档时间: |
|
| 查看次数: |
240 次 |
| 最近记录: |