We are using Azure Search on Sitecore 8.2 update 7 and have enabled switch on rebuild.

This is documented here: https://doc.sitecore.com/developers/91/platform-administration-and-architecture/en/zero-downtime-index-rebuild-in-azure-search.html

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

The issue we are seeing is that when the index is rebuilt (e.g 'my-custom-web-index') it is renamed to 'my-custom-web-index-secondary'. And we are referencing it by name as 'my-custom-web-index' when querying it using the content search API, this then results in not being able to find the index and therefore returning no results - since it is now called 'my-custom-web-index-secondary'.

My understanding is that the primary index name is stored in the Core database: How is the name of the primary index name stored when using SwitchOnRebuild in Azure Search?

The explanation of how switch on rebuild works is as follows:

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.

However this doesn't really explain what the index is renamed to.

Does the name of the index bounce between 'my-custom-web-index-secondary' and 'my-custom-web-index' each time it's rebuilt?

Is this the expected functionality? and if so how do I go about querying it using the content search API?

I had a discussion in Slack with Peter Rydetorp and he suggested that CloudSearchProviderIndex has an GetCloudIndexName method which I could potentially use to get the index name but I'm not quite sure how to go about this.

1 Answer 1


You should not be worried about the actual physical index when doing a query. Your code uses the index ID as in the config, and Sitecore should take care of finding the correct index (at least, that is my experience with 9.0.2). If that is not working in 8.2.7 - call Support ;)

It seems logical as well that your query code should not be aware of any setting regarding switchOnRebuild and such. The underlying Sitecore API that translates the code into the actual query has to take care of that (and normally it does).

In order to debug, try to check the Core properties table to see if the correct index is in there (there are versions -like 9.0.2- with a bug when a server was not alive/awake during a rebuild it might take a wrong index - could happen with staging slots e.g.).

But a first quick check should be the logs. The search logs will give you the exact query that is performed including the index name. You should be able to detect there if the secondary is used or not.

ps: if you need to get to the properties table and don't have db access, I think you can get the values with database.PropertyStore.Get... (not tested)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.