问题描述
我正在寻找一种从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:
-
如果该项目的
_Source
字段不为空,则创建一个Global Item Boosting Rule
以大幅降低提升值.这不是首选方法,因为它只会降低得分并且不会删除得分从搜索结果中克隆出来.
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>
这篇关于全局从索引中排除克隆的项目吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!