DocumentDB创建额外的索引

时间:2017-05-04 06:48:05

标签: azure-cosmosdb

我创建了一个分区集合,我需要DateTime字段上的Range索引(如ISO-8601)和其他几个字段上的哈希索引。这些是我只会过滤的字段,因此我不需要任何其他字段的索引。

我已经定义了我的索引(使用扩展方法):

indexingPolicy.IncludedPaths.Add("/playerId/?", new HashIndex(DataType.Number));
indexingPolicy.IncludedPaths.Add("/category/?", new HashIndex(DataType.String));
indexingPolicy.IncludedPaths.Add("/dateTime/?", new RangeIndex(DataType.String));
indexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/*" });

奇怪的是,当我检查索引策略时,我可以看到创建的许多额外索引对我来说毫无意义。请参阅下面的定义和我的评论。

[{
    "path" : "/playerId/?",
    "indexes" : [{
            "kind" : "Hash",
            "dataType" : "Number",
            "precision" : 3
        }, {
            "kind" : "Hash",
            "dataType" : "String", <<< It created an extra String Hash index
            "precision" : 3
        }
    ]
}, {
    "path" : "/category/?",
    "indexes" : [{
            "kind" : "Hash",
            "dataType" : "String",
            "precision" : 3
        }, {
            "kind" : "Range",
            "dataType" : "Number", <<< It created an extra Number Range index, this field is not numeric and I wanted a String Hash index only
            "precision" : -1
        }
    ]
}, {
    "path" : "/dateTime/?",
    "indexes" : [{
            "kind" : "Range",
            "dataType" : "String",
            "precision" : -1
        }, {
            "kind" : "Range",
            "dataType" : "Number", <<< It created an extra Number Range index, this field is not numeric and I wanted a String Range index only
            "precision" : -1
        }
    ]
}, {

为什么会创建这些索引?

0 个答案:

没有答案