Zero downtime index rebuild in Azure Cognitive Search

Abstract

Avoid Search functionality downtime by using the Azure Cognitive Search Switch On Rebuild feature.

Caution

Azure Cognitive Search will be discontinued in the future and Sitecore will no longer provide support for this service in future releases.

Use the Azure Cognitive Search Switch On Rebuild feature to avoid Search functionality downtime during a full rebuild of the Sitecore Search index.

Note

In scaled environments, the Sitecore instances must have a connection to a shared database (for example: core). Also, in Sitecore.config, set the value of the defaultEventQueue attribute to the shared database.

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.

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 a new index for the full rebuild operation.

  • 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

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