DocumentDB 索引策略中字符串的最佳精度

Best Precision for String in DocumentDB Indexing Policies

我正在为我的 collection 编写索引策略,并试图找出哈希索引中字符串的正确 "Precision",即

collection.IndexingPolicy.IncludedPaths.Add(
new IncludedPath { 
    Path = "/customId/?", 
    Indexes = new Collection<Index> { 
        new HashIndex(DataType.String) { Precision = 20 } } 
});

会有大约10,000个不同的customId,那么什么是正确的"Precision"?如果它获得超过 100,000,000 个 ID 怎么办?

There will be around 10,000 different customId, so what is the right "Precision"? What if it gets more than 100,000,000 ids?

正如 Andrew Liu 在 中所说:哈希索引的索引精度表示将 属性 值哈希到的字节数。

正如我们所知,1 个字节 = 8 位,可以容纳 2^8 = 256 个值。 2 个字节可以容纳 2^16 = 65,536 个值,依此类推。您可以进行类似的计算,以根据您希望包含 属性 customId 路径的文档数量获得索引精度。

此外,您可以参考this article中的索引精度部分​​以及索引存储开销和查询性能之间的权衡指定索引精度。