Better string precision in DocumentDB indexing policy

I am writing an indexing policy for my collection and am trying to figure out what the exact "precision" is for String in the hash index, i.e.

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

      

There will be about 10,000 different customIds, so what is the correct "fidelity"? What if he gets over 100,000,000 IDs?

+3


source to share


1 answer


There will be about 10,000 different customIds, so what is the correct "fidelity"? What if he gets over 100,000,000 IDs?

As Andrew Liu said in this thread : The indexing precision for a hash index specifies the number of bytes for the hash value of a property.



And as we know, 1 bytes = 8 bits, which can hold 2 ^ 8 = 256 values. 2 bytes can contain 2 ^ 16 = 65,536 values, etc. You can do a similar calculation to get the indexing precision based on the number of documents expected to contain the customId property path.

Alternatively, you can refer to the section on index precision in this article and the trade-off between index store overhead and query when specifying index precision.

+1


source







All Articles