Sitecore Solr remove versions from index

天涯浪子 提交于 2019-12-23 08:29:31

问题


I’m using Sitecore 7 and the Solr Search provider. I currently have the site setup to update the search index when publishing an item.

I’ve noticed that when the CMS author creates different versions of an item and then submits these into the index the previous version of the item is not removed from the index, so the index contains multiple versions of the same Sitecore item.

Does anyone know of any settings, that I can change, to make sure that the previous version is removed from the index before adding the new version?

I’ve tried running some code like below to remove the items from the index just before publishing, but the Delete method on the index doesn’t seem to delete anything.

var indexableItem = (SitecoreIndexableItem)item;
ContentSearchManager.GetIndex(index).Delete(indexableItem.UniqueId

Any help much appreciated.


回答1:


I contacted Sitecore on this one and they have said that this is likely to be a bug and they are investigating.

As a workaround, Sitecore recommend using the Inbound and Outbound filters to filter items in the index.

Here's some more information on that:

http://www.sitecore.net/Community/Technical-Blogs/Sitecore-7-Development-Team/Posts/2013/04/Sitecore-7-Inbound-and-Outbound-Filter-Pipelines.aspx

UPDATE: @Jason in the comments below pointed out that is now a support fix for this - see knowledge base article - https://kb.sitecore.net/articles/992608




回答2:


Do you really need to remove the old versions? There is a virtual field defined for you to use to filter for the latest version. Just add a property like this to your POCO (or base class) and use it to filter in your Linq query:

[IndexField("_lastestversion")]
public bool IsLatestVersion { get; set; }

Note that the name of the field is different in the default Solr config (_lastestversion) than it is in the Lucene config (_latestversion).



来源:https://stackoverflow.com/questions/20124996/sitecore-solr-remove-versions-from-index

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!