作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在通过 Azure 门户“查询资源管理器”执行简单查询。
这是我的查询:
SELECT * FROM c
WHERE c.DataType = 'Fruit'
AND c.ExperimentIdentifier = 'prod'
AND c.Param = 'banana'
AND Contains(c.SampleDateTime, '20171029')
ORDER BY c.SampleDateTime DESC
但是,我得到了异常(exception):
Order-by item requires a range index to be defined on the corresponding index path.
没有关于该错误的帮助链接,我无法从该错误消息中辨别出正面。
这是什么意思,为什么我的查询失败以及如何修复它?
P.S. _ts
属性对我来说没有好处,因为我不想在插入记录时进行排序。
最佳答案
ORDER BY 直接从索引提供,因此它要求按项目进行范围索引(而不是哈希索引)。
虽然您只能将排序项索引为范围(对于数字和字符串),但我的建议是将所有路径索引为范围,精度为 -1。
基本上,您需要将集合的索引策略更新为如下所示:
{
"automatic": true,
"indexingMode": "consistent",
"includedPaths": [
{
"path": "/",
"indexes": [
{ "kind": "Range", "dataType": "Number", "precision": -1 },
{ "kind": "Range", "dataType": "String", "precision": -1 }
]
}
]
}
关于Azure CosmosDb : Order-by item requires a range index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47015229/
我是一名优秀的程序员,十分优秀!