Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate API: provide more verbose explanation #10147

Conversation

Projects
None yet
4 participants
@alexksikes
Copy link
Contributor

alexksikes commented Mar 18, 2015

For Fuzzy Queries:

GET /imdb/movies/_validate/query?explain=true
{
  "query": {
    "fuzzy": {
      "actors": "kyle"
    }
  }
}

Response:

{
   ...
   "explanations": [
      {
         "index": "imdb",
         "valid": true,
         "explanation": "filtered(actors:eyle^0.75 actors:kale^0.75 actors:kayle^0.75 ... )->cache(_type:movies)"
      }
   ]
}

For More Like This:

GET /imdb/movies/_validate/query?explain=true
{
  "query": {
    "more_like_this": {
      "like": {
        "_id": "88247"
      }
    }
  }
}

Response:

{
   ...
   "explanations": [
      {
         "index": "imdb",
         "valid": true,
         "explanation": "filtered((((title:terminator^3.71334 plot:kyle^1.0604408 plot:cyborg^1.0863208 ... )~2)) -ConstantScore(_uid:movies#88247))->cache(_type:movies)"
      }
   ]
}

Relates to #1412

Validate API: provide more verbose explanation
For Fuzzy Queries:

```
GET /imdb/movies/_validate/query?explain=true
{
  "query": {
    "fuzzy": {
      "actors": "kyle"
    }
  }
}

Response:

{
   ...
   "explanations": [
      {
         "index": "imdb",
         "valid": true,
         "explanation": "filtered(actors:eyle^0.75 actors:kale^0.75 actors:kayle^0.75 ... )->cache(_type:movies)"
      }
   ]
}
```

For More Like This:

```
GET /imdb/movies/_validate/query?explain=true
{
  "query": {
    "more_like_this": {
      "like": {
        "_id": "88247"
      }
    }
  }
}

Response:

{
   ...
   "explanations": [
      {
         "index": "imdb",
         "valid": true,
         "explanation": "filtered((((title:terminator^3.71334 plot:kyle^1.0604408 plot:cyborg^1.0863208 ... )~2)) -ConstantScore(_uid:movies#88247))->cache(_type:movies)"
      }
   ]
}
```

Relates to #1412
@@ -188,7 +191,7 @@ protected ShardValidateQueryResponse shardOperation(ShardValidateQueryRequest re

valid = true;
if (request.explain()) {
explanation = searchContext.query().toString();
explanation = searchContext.query().rewrite(searcher.reader()).toString();

This comment has been minimized.

Copy link
@javanna

javanna Mar 18, 2015

Member

Not very expert on this aspect but I wonder if and how rewriting affects other queries explain output? Also, tests would help here just to validate what we print out.

@alexksikes alexksikes added the review label Mar 19, 2015

@s1monw s1monw self-assigned this Mar 20, 2015

@s1monw

This comment has been minimized.

Copy link
Contributor

s1monw commented Mar 20, 2015

I think this LGTM - I wonder if we should make the rewrite optional and add a boolean to the request to trigger it?

@alexksikes

This comment has been minimized.

Copy link
Contributor Author

alexksikes commented Mar 20, 2015

I wondered this too if I should not add a verbose flag, but the slight problem is when the query is not valid, in this case, the explanation of the error is not more verbose. So the explain flag should explain the error if the query is not valid, and otherwise should explain the query itself if valid.

@s1monw

This comment has been minimized.

Copy link
Contributor

s1monw commented Mar 20, 2015

just add rewrite: true|false?

@alexksikes

This comment has been minimized.

Copy link
Contributor Author

alexksikes commented Mar 20, 2015

rewrite: true|false would only make sense if explain: true then. I agree that this is more descriptive as to what is actually happening, but wondering if having to set two flags explain: true and rewrite: true is a good pattern for the task. Perhaps @clintongormley has some ideas.

@clintongormley

This comment has been minimized.

Copy link
Member

clintongormley commented Apr 4, 2015

I can imagine this output could be quite heavy, so I'd be happy having the extra rewrite:true flag. The other place I'd love to see this is in the common_terms query and the match query when combined with cutoff_frequency.

@alexksikes alexksikes added >feature and removed >enhancement labels Apr 9, 2015

@s1monw

This comment has been minimized.

Copy link
Contributor

s1monw commented Apr 13, 2015

LGTM

alexksikes added a commit that referenced this pull request Apr 13, 2015

Validate API: support for verbose explanation of succesfully validate…
…d queries

This commit adds a `rewrite` parameter to the validate API in order to shown
how the given query is re-written into primitive queries. For example, an MLT
query is re-written into a disjunction of the selected terms. Other use cases
include `fuzzy`, `common_terms`, or `match` query especially with a
`cutoff_frequency` parameter. Note that the explanation is only given for a
single randomly chosen shard only, so the output may vary from one shard to
another.

Relates #1412
Closes #10147

@alexksikes alexksikes deleted the alexksikes:enhancement/validate-verbose-explain branch Apr 13, 2015

@alexksikes alexksikes removed the review label Apr 14, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.