willholley commented on issue #5756:
URL: https://github.com/apache/couchdb/issues/5756#issuecomment-3562138060

   The index isn't used because it can only service queries where all the keyed 
fields (`["type", "fullname", "shortname", "url"]`) must exist in the result 
set. This is mentioned in 
https://docs.couchdb.org/en/stable/api/database/find.html#find-index-selection, 
but the reason for index exclusion in `_explain` is unhelpful/incorrect by the 
looks of it.
   
   The fix is to change the selector to:
   
   ```json
   "selector": {
       "type": {
         "$eq": "vendor"
       },
       "shortname": {
         "$exists": true
       },
       "url": {
         "$exists": true
       }
   }
   ```
   
   I'll also note that you could equally use a view for this. Mango is just 
using a view under the hood but allows you to filter the view results before 
returning the result. If you don't need/want the additional filtering, the 
sorting and 
[pagination](https://docs.couchdb.org/en/stable/ddocs/views/pagination.html) 
capabilities in views are the same.
   
   
   
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to