这是我的查询:
{
"selector": {
"_id": {
"$regex": "^rati" //need to find all documents in ratings partition
}
},
"fields": [
"MovieID",
"UserId",
"Rating"
],
"limit": 10,
"sort": [
{
"MovieID": "asc"
}
]
}
[当我运行此查询时,出现该错误:Error running query. Reason: (no_usable_index) No global index exists for this sort, try indexing by the sort fields.
如果我删除
"sort": [
{
"MovieID": "asc"
}
]
一切正常。老实说我快疯了,我不明白我哪里错了。
我已经尝试过此查询:
{
"selector": {
"_id": {
"$regex": "^rati"
},
"MovieID": {
"$gte": 0
}
},
"fields": [
"_id",
"MovieID",
"UserId",
"Rating"
],
"limit": 10,
"sort": [
{
"_id": "asc"
}
]
}
但相同。
MovieID
字段必须是选择器的一部分。
在此尝试:
{
"selector": {
"_id": {
"$regex": "^rati" //need to find all documents in ratings partition
},
"MovieID": {"$gte": 0} // include MovieID, If the ID is non-numeric change the selecor type.
},
"fields": [
"MovieID",
"UserId",
"Rating"
],
"limit": 10,
"sort": [
{
"MovieID": "asc"
}
]
}