Cosmos重新索引花费的时间比预期的长

时间:2019-10-22 06:51:03

标签: indexing azure-cosmosdb cosmos

Cosmos重新编制索引所需的时间比预期的长。 有什么办法可以检查分区集合是否仍在进行重新索引。 即使我将索引策略设置为无并保持一致,查询仍会引发错误。

1 个答案:

答案 0 :(得分:0)

您可以通过阅读GET集合中的x-ms-documentdb-collection-index-transformation-progress标头查看进度百分比。例如,在.NET中,您可以运行以下代码段:

// 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"]);

此处有更多详细信息:https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-manage-indexing-policy#updating-indexing-policy