Switch Commerce indexes during rebuild
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 or SolrCloud 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 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:
-
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). -
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
). -
Open the folder that contains the Solr schema of the active core, for example the
SolrSchemas/YOURCORE
folder.NoteSitecore 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.
-
Copy the files
managed-schema
andsolrconfig.xml
to the conf folder you create in step 2 (for exampleC:\solr-*. *.*\server\solr\YOURCOREFOLDER-Rebuild\YOURCORENAME\conf
). -
Open a browser window, and in the URL, replace the value used for
"name="
with the name of the new core to create, for examplehttps://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.
-
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:RequestResponse{ "$type": "Sitecore.Commerce.Plugin.Search.SearchScopePolicy, Sitecore.Commerce.Plugin.Search", "Name": "YOURCORENAME", {
-
Define the configuration parameters for your core. As an example, the following shows the configuration of the CatalogItemsScope index with SwitchOnRebuild enabled.
RequestResponse{ "$type": "Sitecore.Commerce.Plugin.Search.SearchScopePolicy, Sitecore.Commerce.Plugin.Search", "Name": "CatalogItemsScope", "CurrentIndexName":"CatalogItemsScope", "SwitchOnRebuild": true, "SwitchOnRebuildReset": false, "SwitchOnRebuildClearPreviousIndex": true, "SwitchOnRebuildPrimaryIndexName":"CatalogItemsScope", "SwitchOnRebuildSecondaryIndexName":"CatalogItemsScope-Rebuild", }
SwitchOnRebuild configuration parameters
The following table describes the configuration parameters for the switch on rebuild feature:
Parameter |
Description |
---|---|
Name |
The name of the index. |
CurrentIndexName |
The name (string) of the search index that is currently active. |
SwitchOnRebuild |
Enables or disables the SwitchOnRebuild feature for full index rebuilding operations. Default: true |
SwitchOnRebuildPrimaryIndexName |
Name of the primary index. Determines which index to fully rebuild by alternating, and then sets the |
SwitchOnRebuildSecondaryIndexName |
Name of the secondary index. Determines which index to fully rebuild by alternating , and then sets the |
SwitchOnRebuildClearPreviousIndex |
When enabled, deletes all documents in the previous index after the switch. Default: true |