您可以创建自定义爬虫并在其中添加逻辑以排除克隆的项目。
我正在考虑的方法是创建一个继承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
元素并指向您所在的类。