1
我有一个问题持续了几天,我无法解决。Cloudant:此类索引不存在,请尝试按排序字段索引
我有我的数据库一个简单的文件,它看起来像这样:
{
"_id": "asd123",
"_rev": "revidasd123",
"type": "CUSTOM_TYPE",
"position": 8,
"title": "Short custom title"
}
当我试图通过位置做一个排序,即使我已经创造了这方面的指标,我总是得到同样的错误:
Error: no_usable_index. Reason: No index exists for this sort, try indexing by the sort fields.
这里是指数:
{
"type": "json",
"def": {
"fields": [
{
"position": "asc"
}
]
}
}
这里是我的查询造成此错误:
{
"selector": {
"type": "CUSTOM_TYPE",
"_id":{
"$gt": null
}
},
"fields": [
"_id",
"type",
"position"
],
"sort": [
{
"_id": "asc"
},
{
"position": "asc"
}
]
}
结果:没有索引存在这种排序,按排序领域尝试建立索引。
请帮助!在此先感谢
非常感谢@markwatsonatx。 这解决了我的问题。 我也包括在选择器中的位置,但我没有删除_id,所以可能也会给我一个错误。 – Alin