azure - DocumentDB 是否提供自动索引?

标签 azure azure-cosmosdb

documentDB 的文档表明它在这里提供自动索引: https://azure.microsoft.com/en-us/documentation/articles/documentdb-indexing/

但它的示例代码(在 Azure 门户上)显示了手动索引策略创建,如下所示:

DocumentCollection collectionInfo = new DocumentCollection();
collectionInfo.Id = collectionName;
// Configure collections for maximum query flexibility including string range queries.
collectionInfo.IndexingPolicy = new IndexingPolicy(new RangeIndex(DataType.String) {
    Precision = -1
});

如果documentDB提供了自动索引,那为什么我还需要再次手动创建索引策略?

最佳答案

每个字段都有一个默认的 3 字节哈希索引。您可以使用索引策略设置覆盖特定字段/类型的索引策略。如果您想要范围索引或想要更改索引的精度,可以使用策略来实现。您需要在任何要使用 ORDER BY 以及其他常见用途的字段上设置范围索引。所以,是的,这两种说法都是正确的。它提供自动索引,但您也可以指定索引。

关于azure - DocumentDB 是否提供自动索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38549373/

相关文章:

azure - ARM API 支持应用程序权限吗?

hadoop - 如何将数据从DocumentDB中的多个集合中获取到Hadoop

azure - DocumentDB REST API : x-ms-documentdb-partitionkey is invalid

azure - Cosmos DB 中的事件 ID 是什么?

azure - WebApp 降级到 D1 删除 SSL

azure - 在服务器上找不到 HTML 5 视频 url,但在本地工作

c# - 在 Azure Function 中处理从查询到 Azure IOT Hub 的 JSON 响应

c# - 在 Azure Functions 中调用 WCF 服务

asp.net-core - 核心的 DocumentDB TransientFaultHandling

azure-functions - 从函数应用访问虚拟网络中的 Cosmos DB