Reputation: 6735
Error:
No index exists for this sort, try indexing by the sort fields.
I've tried creating indexes on anotherValue
, _id+anotherValue
, but no difference.
This is my query:
{
"selector": {
"_id": { "$gt": null },
"$or": [
{ "_id": "10" },
{ "value": "10", "anotherValue": "1234" }]
},
"sort": [{"anotherValue": "desc"}]
}
Indexes setup:
Your available Indexes:
special: _id
Upvotes: 0
Views: 1499
Reputation: 3491
Try adding a desc index on anotherValue:
{
"index": {
"fields": [
{"anotherValue":"desc"}
]
},
"type": "json"
}
and change your query to this:
{
"selector": {
"anotherValue": { "$gt": null },
"$or": [
{ "_id": "10" },
{ "value": "10", "anotherValue": "1234" }
]
},
"sort": [{"anotherValue": "desc"}]
}
Note: Your original query would also work if you added a text index on all fields:
{
"index": {},
"type": "text"
}
Upvotes: 2