Microsoft Azure 文档 BadRequestException 使用针对未范围索引的路径的筛选器指定了无效查询。考虑在请求中添加允许扫描 header 。
我的查询是:
SELECT c.id FROM users c WHERE (c.lat < 29.89)
结束了?文档数量(因为 DocumentDB 无法获取集合中的文档数量)
最佳答案
如果您查看此处的博文: http://azure.microsoft.com/blog/2015/01/27/performance-tips-for-azure-documentdb-part-2/
Indexing Policy Tip #3: Specify range index path type for all paths used in range queries
DocumentDB currently supports two index path types: Hash and Range. Choosing an index path type of Hash enables efficient equality queries. Choosing an index type of Range enables range queries (using
>, <, >=, <=)
.
它给出了 C# 中添加范围索引以使路径具有可比性的示例,但 node.js library. 中也有类似的功能。
创建集合时,可以通过body参数传递IndexingPolicy。 IndexingPolicy
有几个成员。其中之一是 IncludedPaths,您可以在其中定义索引。
var policy = {
Automatic: true,
IndexingMode: 'Lazy',
IncludedPaths: [
{
IndexType: "Range",
Path: "path to be indexed (c.lat)",
NempericPrecission: "1",
StringPrecission: "1"
}
],
ExcludedPaths: []
}
client.createCollection(
'#yourdblink',
{
id: 10001,
indexingPolicy: policy
});
关于azure - DocumentDB - 无法比较查询中的两个路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28418772/