1

我正在寻找一种优雅的方式来从我的网络索引中排除克隆项目。我的搜索结果中出现重复项。如果只出现原始项目并且根本没有克隆,我会更喜欢它。

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

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

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

站点核心 v7.1

4

2 回答 2

5

您可以创建自定义爬虫并在其中添加逻辑以排除克隆的项目。
我正在考虑的方法是创建一个继承Sitecore.ContentSearch.SitecoreItemCrawler并覆盖该DoAdd()方法的类。
像这样的东西:

protected override void DoAdd(IProviderUpdateContext context, SitecoreIndexableItem indexable)
{
    Assert.ArgumentNotNull((object) context, "context");
    Assert.ArgumentNotNull((object) indexable, "indexable");

    if (!indexable.Item.IsClone)
    {
        base.DoAdd(context, indexable);
    }
}

然后你需要设置你的爬虫配置来使用你的自定义爬虫。
Sitecore.ContentSearch.<Lucene/Solr>.Index.<databasename>.config文件中定义使用哪些爬虫。
您需要更新contentSearch/configuration/indexes/locations/crawler元素并指向您所在的类。

于 2013-12-18T09:25:19.963 回答
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;
        }
    }
}

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

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

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

于 2015-05-26T13:07:16.827 回答