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