pgj opened a new pull request, #4662:
URL: https://github.com/apache/couchdb/pull/4662

   Execution of `_find` queries is often considered opaque by the users.  They 
do not have enough insights about which index was selected and why, which can 
make hard to compose better queries.  To address these problems, the change 
proposes to extend the `/{db}/_explain` endpoint with the following:
   
   - `index_candidates`: This attribute contains the list of all the other 
indexes that were not chosen for serving the query.  The items in the list tell 
whether the given index is usable, what the reason was for its exclusion, and 
how "far" it is from being selected.
   - `selector_hints`: This attribute shows which fields are indexable and 
unindexable in the selector per each (available) index kind.
   
   Samples, `index_candidates`:
   
   ```json
     "index_candidates": [
       {
         "index": {
           "ddoc": null,
           "name": "_all_docs",
           "type": "special",
           "def": {
             "fields": [
               {
                 "_id": "asc"
               }
             ]
           }
         },
         "usable": false,
         "reason": "unfavored_type",
         "ranking": 1
       },
       {
         "index": {
           "ddoc": "_design/age",
           "name": "age",
           "type": "json",
           "partitioned": false,
           "def": {
             "fields": [
               {
                 "age": "asc"
               }
             ]
           }
         },
         "usable": false,
         "reason": "field_mismatch",
         "ranking": 2,
         "covering": false
       }
     ]
   ```
   
   and `selector_hints`:
   
   ```json
     "selector_hints": {
       "indexable_fields": {
         "json": [],
         "text": [
           "name.first"
         ],
         "nouveau": [
           "name.first"
         ]
       },
       "unindexable_fields": {
         "json": [
           "name.first"
         ],
         "text": [],
         "nouveau": []
       }
     }
   ```
   
   Based on this information, Fauxton could display more useful hints and tips 
for the users on building the queries.
   
   As an extra, the unit test coverage is increased throughout the Mango 
modules.
   
   ## Remaining items
   
   - [ ] Finish unit tests
   - [ ] Document the index selection process, possibly with nice diagrams
   - [ ] `_explain` should not return HTTP 400 when there is no usable index
   
   ## Checklist for the review
   
   - [ ] Code is written and works correctly
   - [ ] Changes are covered by tests
   - [ ] Documentation changes were made in the `src/docs` folder
   


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