Switch Solr Index

Rebuilding of index is a very common scenario if your website is built on Sitecore. During the maintenance of the websites, you come in the situation when you have to rebuild your indexes.

Here the question is, what is the problem in triggering index rebuild event? The answer is, while performing index rebuild activity you will not be able to make any search on that particular core/index. So during that period you website would be either completely down or some functionality would be down during index rebuild. Duration of this activity completely depends on the index/core size. Sometime it takes few hours.

Next question is, what the solution of the above issue.

So if we can create a duplicate/secondary index of that particular index and perform the rebuild on the secondary index. Once the rebuilding and the optimization of the index completes, Sitecore switches the rebuilt and optimized index is used.

SwitchOnRebuildSolrSearchIndex

SwitchOnRebuildSolrSearchIndex will help us in achieving this. Below are the steps to switch Solr index:

Step: 1. Create a secondary/duplicate core

  • Copy the existing core (for example: sitecore_web_index) folder
  • Rename the copied folder with stecore_web_index_rebuild (you can put any name)
  • Update the core name. Open the file core.properties in the notepad and update the newly renamed core name (sitecore_web_index_rebuild) as per above example.
  • Restart the SOLR server.
  • Check your SOLR URL (https://localhost:8983/solr/). You will find the newly created core here.

Step-2: Update configuration

  • Open the index configuration file (\App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.Solr.Index.Web.config) as per given example above. Every index would have seperate configuration file.
  • Change type reference
  • Add rebuildcore parameter

Switch_Solr_index

That’s all.

Thanks and have a good day ahead.

Leave a comment