Tuesday, March 8, 2016

Sitecore accessing a search index whilst it is rebuilding

Depending on the indexing strategy of your Sitecore search index, there will be time when the index needs to rebuild. This may be at the end of publish (onPublishEndAsync) or even after a full publish (rebuildAfterFullPublish). What you might not realize is that the index will be unavailable (and therefore the search itself) during this republish. This is not best practice as it can ;lead to large amounts of downtime depending  on the size of the index and how often it's rebuilt.
Luckily there is a solution where Sitecore will keep two versions of the search index, so that whilst one is being rebuilt, another will be available for querying. This can be enabled on the main XML definition of your Lucene search index.

A standard Lucene search index might be defined by:
<index id="MyIndex" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
 However to enable the duplication of index, you will need to set the type to SwitchOnRebuildLuceneIndex.
<index id="MyIndex" type="Sitecore.ContentSearch.LuceneProvider.SwitchOnRebuildLuceneIndex, Sitecore.ContentSearch.LuceneProvider">
Please be aware that this will then require double the storage space (as there are two versions of the index) and it's always worth investigating your indexing strategy to ensure it meets the given Sitecore implementations needs.

No comments:

Post a Comment