hamiltonsalazar opened a new issue #2971:
URL: https://github.com/apache/couchdb/issues/2971
[NOTE]: # ( ^^ Provide a general summary of the issue in the title above. ^^
)
## Description
I followed the instructions in the documentation for [POST
/{db}/_find](https://docs.couchdb.org/en/stable/api/database/find.html#post--db-_find),
but that doesn't work for me
[NOTE]: # ( Describe the problem you're encountering. )
[TIP]: # ( Do NOT give us access or passwords to your actual CouchDB! )
## Current Behaviour
I have a database "views" with different documents. I want to find documents
using a declarative JSON querying syntax, i try with the example query in the
documentation:
```POST /movies/_find HTTP/1.1
Accept: application/json
Content-Type: application/json
Content-Length: 168
Host: localhost:5984
{
"selector": {
"year": {"$gt": 2010}
},
"fields": ["_id", "_rev", "year", "title"],
"sort": [{"year": "asc"}],
"limit": 2,
"skip": 0,
"execution_stats": true
}
```
For me i use the below query:
`curl -X POST http://anna:[email protected]:5984/views/_find -H "Accept:
application/json" -H "Content-Type: application/json" -d "{ \"selector\": {
\"year\": {\"$gt\": 2010} }, \"fields\": [\"_id\", \"_rev\",
\"year\", \"title\"], \"sort\": [{\"year\": \"asc\"}], \"limit\": 2,
\"skip\": 0, \"execution_stats\": true}"`
But CouchDB responded with:
`{"error":"no_usable_index","reason":"No index exists for this sort, try
indexing by the sort fields."}`
## Expected Behaviour
When i query CouchDB would response with:
`{"_id":"4d09da4324f9677d997396179c00b05f","_rev":"9-4ca2559289e18e87aadd6d024f8d6d83","year":2011,"title":"FishStew"},
{"_id":"4d09da4324f9677d997396179c021aae","_rev":"3-6791270dc777bf9f260961858e7b569e","year":2019,"title":"BeefStew"}
],
"bookmark":
"g1AAAABweJzLYWBgYMpgSmHgKy5JLCrJTq2MT8lPzkzJBYormKQYWKYkmhgbmaRZmpmbp1hamhtbmhmaWyYbGBkmJqaC9HHA9BGlIwsAd-sdew",
"execution_stats":
{"total_keys_examined":0,"total_docs_examined":3,"total_quorum_docs_examined":0,"results_returned":2,"execution_time_ms":1.0},`
[NOTE]: # ( Tell us what you expected to happen. )
## Your Environment
[TIP]: # ( Include as many relevant details about your environment as
possible. )
[TIP]: # ( You can paste the output of curl http://YOUR-COUCHDB:5984/ here.
)
* CouchDB version used: 3.1.0
* Operating system and version: Windows 10 Pro 1909
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]