Zero downtime index rebuild in Azure Search

Current version: 9.0
Important

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.

Note

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 is 00:01:00 (1 minute). You can only use this when the SwitchOnRebuild 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.

    Note

    When a rebuild is scheduled, the Sitecore Azure Search provider creates a secondary index called sitecore-master-index-xxx. When the reindex finishes, the sitecore-master-index-xxx becomes the primary and the sitecore-master-index is deleted after a few minutes, (you can check this in the ContentSearch.Azure.SwitchOnRebuildCleanUpDelay configuration file).

    All index-update operations are postponed during a rebuild process.

Do you have some feedback for us?

If you have suggestions for improving this article,