Sitecore Solr removes versions from an index

Im using Sitecore 7 and the search provider Solr. Currently, I have a site setup to update the search index when publishing an item.

Ive noticed that when a CMS author creates different versions of an element and then submits them to the index, the previous version of the element is not removed from the index, so the index contains several versions of the same Sitecore element.

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

Ive tried to run some code, as shown below, to remove items from the index immediately before publishing, but the Delete method in the index does not delete anything.

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

Any help is greatly appreciated.

+8
c # solr sitecore sitecore7
source share
2 answers

I contacted Sitecore on this and they said that this would probably be a mistake and they are investigating.

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

Here is more information about this:

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 indicated that this is a fix for support now - see the Knowledge Base article - https://kb.sitecore.net/articles/992608

+3
source share

Do you really need to remove old versions? A virtual field is used to filter the latest version. Just add a property similar 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 field name is different in the default Solr configuration (_lastestversion) than in the Lucene configuration (_latestversion).

+2
source share

All Articles