Zero downtime index rebuild in Azure Search
Azure Search will be discontinued in the future and Sitecore will no longer provide support for this service in future releases.
Use the Azure Search Switch On Rebuild feature to avoid Search functionality downtime during a full rebuild of the Sitecore Search index.
The SwitchOnRebuild feature requires that access to the system EventQueue table is shared by all Sitecore instances in a scaled environment. For more information, refer to Configure Sitecore roles for separate EventQueue, Properties, and Tasks tables.
Controlling the Switch On Rebuild feature
A full index rebuild executes in a separate rebuild index. When the rebuild operation finishes, Sitecore switches the Search service to use the new rebuilt index as the primary search index. After this, Sitecore deletes the previous Search index.
You can control the Switch On Rebuild feature with the following index configuration settings:
-
<setting name="ContentSearch.Azure.SwitchOnRebuild" value="true"/>
To avoid downtime of the Search functionality during an index rebuild, use this setting to specify whether the Azure Search provider uses the SwitchOnRebuild functionality. The default value is true. -
<setting name="ContentSearch.Azure.SwitchOnRebuildCleanUpDelay" value="00:01:00"/>
You can set a time buffer to prevent Sitecore deleting the old index before all of the roles have been switched over to work with the newly rebuilt index. The default value is00:01:00
(1 minute). You can only use this when theSwitchOnRebuild
feature is enabled.
The Switch On Rebuild process
After a power user requests a full rebuild of the Sitecore Search index(es), the following process takes place:
-
The Sitecore Azure Search provider creates and populates a new
sitecore-master-index
for the full rebuild operation, which is used as the primary index. -
While Sitecore writes data into the new index, the search provider continues to use the old one.
-
When the full rebuild is complete, the Sitecore Azure Search provider sends a corresponding remote event (
index:switchonrebuild
) to all roles. -
Each role processes the remote
'index:switchonrebuild'
event and switches the search service over to work with the newly rebuilt index. -
The
SwitchOnRebuildCleanUpDelay
setting controls the delay that allows other roles to process the remote event and switch index. -
After the time-buffer delay runs out (controlled by the
SwitchOnRebuildCleanUpDelay
setting), and the rebuilt index becomes the primary search index, Sitecore deletes the previous search index. This delay allows the other roles time to process the remote event and switch indexes.NoteWhen a rebuild is scheduled, the Sitecore Azure Search provider creates a secondary index called
sitecore-master-index-xxx
. When the reindex finishes, thesitecore-master-index-xxx
becomes the primary and thesitecore-master-index
is deleted after a few minutes, (you can check this in theContentSearch.Azure.SwitchOnRebuildCleanUpDelay
configuration file).All index-update operations are postponed during a rebuild process.