Search code examples
indexingazure-cosmosdbcosmos

Cosmos re-indexing takes longer than expected


Cosmos re-indexing takes longer than expected. Is there any way i can check if re-indexing is still happening for partitioned collection. Even though I made the index policy to none and kept back consistent, the query is throwing an error.


Solution

  • You can view the percentage progress by reading the x-ms-documentdb-collection-index-transformation-progress header in GET collection. For example in .NET, you can run the following snippet:

    // retrieve the container's details
    ContainerResponse containerResponse = await client.GetContainer("database", "container")
        .ReadContainerAsync(new ContainerRequestOptions { PopulateQuotaInfo = true });
    // retrieve the index transformation progress from the result
    long indexTransformationProgress = long.Parse(
        containerResponse.Headers["x-ms-documentdb-collection-index-transformation-progress"]);
    

    More details here: https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-manage-indexing-policy#updating-indexing-policy