Switch Commerce indexes during rebuild

Current version: 9.3

You use the SwitchOnRebuild feature to ensure high availability of search capability during full rebuilding of Commerce indexes. The SwitchOnRebuild feature prevents downtime of search capability, for example, allowing users to continue searching for items, while a complete search index rebuild is in progress.

You can use the SwitchOnRebuild feature with the Solr, SolrCloud, or Azure search provider.


The SwitchOnRebuild feature is enabled by default on the following Commerce indexes: CatalogItemsScope, CustomersScope, OrdersScope, PromotionsScope, and PriceCardsScope.

The SwitchOnRebuild feature relies on a primary and a secondary instance of the same index. When you run the full index minion to rebuild your search index with the SwitchOnRebuild feature enabled, the index rebuilding process occurs on a secondary (non-live) index, while the primary (active) index continues to provide search capability on the live storefront site. Once the rebuilding of the secondary index completes, the indexes switch and the newly rebuilt index becomes the active search index.

Set up your custom Commerce index to switch on rebuild

You can set up custom indexes in your Commerce deployment to switch on rebuild.

Create a duplicate of the Solr core to use as the secondary index

If you use Solr as your search provider, you must manually create the secondary index necessary for the switch to occur. You create the secondary index by making a duplicate of the active Solr core.


If your Commerce deployment uses Azure Search or SolrCloud as a search provider, you do not need to create a secondary index manually (they are created automatically). However, you must configure SwitchOnRebuild for your custom index.

To duplicate a Solr core:

  1. Open the folder containing your Solr core, for example, C:\solr-8.1.1\server\solr, and create a sub-folder (for example, YOURCOREFOLDER-Rebuild).

  2. Open the folder C:\solr-*.*.*\server\solr\configsets\sample_techproducts_configs, and copy the conf folder in the sub-folder you created in step 1 (for example, C:\solr-*.*.*\server\solr\YOURCOREFOLDER-Rebuild).

  3. Open the folder that contains the Solr schema of the active core, for example the SolrSchemas/YOURCORE folder.


    Sitecore XC Solr schemas are available in the SolrSchemas folder of the SolrSchemas.Sitecore.Commerce.x.x.x zip file, included in the Sitecore XC release package.

  4. Copy the files managed-schema and solrconfig.xml to the conf folder you create in step 2 (for example C:\solr-*. *.*\server\solr\YOURCOREFOLDER-Rebuild\YOURCORENAME\conf).

  5. Open a browser window, and in the URL, replace the value used for "name=" with the name of the new core to create, for example https://localhost:8994/solr/admin/cores?action=name=YOURCORENAME&configset=sample_techproducts_configs&property.update.autoCreateFields=false, and then browse to that URL. Now that you have created the new core, you can configure SwitchOnRebuild.

Configure SwitchOnRebuild for a custom Commerce index

To configure SwitchOnRebuild:


If you use Solr as your search provider, you must create a duplicate of the active Solr core before your enable the SwitchOnRebuild feature.

  1. Open the wwwroot\data\Environments\PlugIn.Search.PolicySet-1.0.0.json file, and locate the section that contains the configuration of the active index. For example:

     "$type":  "Sitecore.Commerce.Plugin.Search.SearchScopePolicy, Sitecore.Commerce.Plugin.Search",
     "Name": "YOURCORENAME",
  2. Define the configuration parameters for your core. As an example, the following shows the configuration of the CatalogItemsScope index with SwitchOnRebuild enabled.

     "$type":  "Sitecore.Commerce.Plugin.Search.SearchScopePolicy, Sitecore.Commerce.Plugin.Search",
     "Name": "CatalogItemsScope",
     "SwitchOnRebuild": true,
     "SwitchOnRebuildReset": false,
     "SwitchOnRebuildClearPreviousIndex": true,

SwitchOnRebuild configuration parameters

The following table describes the configuration parameters for the switch on rebuild feature:




The name of the index.


The name (string) of the search index that is currently active.


Enables or disables the SwitchOnRebuild feature for full index rebuilding operations.

Default: true


Name of the primary index. Determines which index to fully rebuild by alternating, and then sets the CurrentIndexName property in the SearchStatus entity to persist if rebuilt successful.


Name of the secondary index. Determines which index to fully rebuild by alternating , and then sets the CurrentIndexName property in the SearchStatus entity to persist if rebuilt successful.


When enabled, deletes all documents in the previous index after the switch.  

Default: true

Do you have some feedback for us?

If you have suggestions for improving this article,