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:
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.
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
My approach is like this:
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>