【发布时间】:2017-05-04 06:48:04
【问题描述】:
我创建了一个分区集合,其中我需要 DateTime 字段上的 Range 索引(如 ISO-8601)和其他几个字段上的 Hash 索引。这些是我将仅过滤的字段,因此我不需要任何其他字段的索引。
我已经这样定义了我的索引(使用扩展方法):
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 = "/*" });
奇怪的是,当我检查索引策略时,我可以看到创建了许多对我来说毫无意义的额外索引。请参阅下面的定义和我的 cmets。
[{
"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
}
]
}, {
它为什么要创建这些索引?
【问题讨论】:
标签: azure-cosmosdb