自定义 Tridion 搜索索引处理程序:页面 url 的自定义与标准字段? [英] Customized Tridion Search Index Handler: Custom vs Standard field for page url?

查看:47
本文介绍了自定义 Tridion 搜索索引处理程序:页面 url 的自定义与标准字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SDL Tridion 2011 (GA) 的自定义搜索索引处理程序.我得到了一些工作,使用 Arjen 提供的非常有用的信息,但我不确定我的执行是否是最佳选择.

I was playing around with custom Search Indexing Handlers for SDL Tridion 2011 (GA). I got something working, using the very helpful information provided by Arjen, however I am not sure if my execution is the best option.

要求能够通过 url 搜索 CMS 中的页面(例如 www.example.com/news/index.html).为了做到这一点,我使用 ISearchIndexingHandler 接口(下面的代码)创建了一个类.我正在为项目的 ContentText 字段中的 url 编制索引,但是我不确定这是否通常会包含页面的其他内容(我认为页面只有元数据,所以这应该没问题).使用它而不是自定义字段的优点是我可以简单地在搜索框中输入 url,而不必使用 ;在<字段名>或类似的东西.

The requirement is to be able to search for pages in the CMS by url (eg www.example.com/news/index.html). In order to do this I have the created a class using the ISearchIndexingHandler interface (code below). I am indexing the url in the ContentText field of the item, however I am not sure if this would normally contain something else for a page (I think a page only has metadata so this should be OK). The advantage of using this over a custom field is that I can simply type the url in the search box without having to use <url> IN <fieldname> or something like that.

所以我的问题是,是否有任何理由不对页面使用 ContentText,使用自定义字段是否有任何优势?此外,任何对如何处理 BluePrinting 有好的想法的人都会获得奖励(如果我在父出版物中创建页面,我希望本地 url 也能在子出版物中编入索引),以及结构组路径被更改的情况(我想我可以在我的索引处理程序中以某种方式触发子页面项的重新索引).

So my question is, is there any reason not to use ContentText for Pages, and is there any advantage in using a custom field? Also bonus marks go to anyone with good ideas on how to handle BluePrinting (if I create a page in a parent publication, I want the local urls also to be indexed in the child publications), and the case where a Structure group path is altered (I guess I can somehow trigger a re-index of child page items from within my indexing handler).

代码:

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 字段用于索引模板内容数据.

You can store the url in the ContextText Property. Thies field is used to index Template content data.

Tridion 不会索引子出版物的共享项目.

Tridion does not index shared item(s) of child publication.

索引在项目修改时触发(创建、更新、删除、本地化和取消本地化).或者您可以使用重新索引工具重新索引您的项目.但是没有办法索引子出版物中的共享项.

Indexing is triggered on Item modification(create, update, delete, localize and unlocalize). Or you can use reindexing tool to reindex ur item. but there is no way to index shared items in child publication.

这篇关于自定义 Tridion 搜索索引处理程序:页面 url 的自定义与标准字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆