本文介绍了全局从索引中排除克隆的项目吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种从Web索引中排除克隆项目的优雅方法.我的项目在搜索结果中显示为重复项.如果只显示原始项目而根本没有克隆,我会更喜欢.

I am looking for an elegant way to exclude cloned items from my web index. I am having items appear as duplicates in my search results. I'd prefer it if only the original items appear and no clones at all.

想到的一些可能的解决方案是:

Some possible solutions that come to mind are to:

  1. 如果该项目的_Source字段不为空,则创建一个Global Item Boosting Rule以大幅降低提升值.这不是首选方法,因为它只会降低得分并且不会删除得分从搜索结果中克隆出来.

  1. Create a Global Item Boosting Rule to drastically lower the boost value if the item's _Source field is not empty. This is not preferred as it only lowers the score and does not remove the clones from the search results.

使用扩展的Where子句在我执行的每个查询中排除克隆的项目.这也不是首选,因为这意味着我需要记住在所有查询中都包括该子句.此外,克隆的项目仍保留在索引中.

Exclude the cloned items in every query that I perform using an extended Where clause. This is also not preferred as it means that I need to remember to include this clause on all queries. Furthermore, the cloned items still remain in the index.

Sitecore v7.1

Sitecore v7.1

推荐答案

我的方法是这样的:

public class InboundIndexFilter : InboundIndexFilterProcessor
{
    public override void Process(InboundIndexFilterArgs args)
    {
        var item = args.IndexableToIndex as SitecoreIndexableItem;

        if (item != null && (!item.Item.Versions.IsLatestVersion() || item.Item.IsClone))
        {
            args.IsExcluded = true;
        }
    }
}

它会跳过克隆版本和非最新版本.然后,我更新了相应的管道设置:

It skips clones and non-latest versions. Then I updated the corresponding pipeline settings:

 <indexing.filterIndex.inbound>
    <processor type="XY.InboundIndexFilter, X.Y.Z"/>
 </indexing.filterIndex.inbound>

有关入站过滤器的更多信息

这篇关于全局从索引中排除克隆的项目吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:31