Reputation: 1314
I'm using ES version 7.9.2 and trying to run the Explain API but the response does not return any explanation result, what could be the reason?
Here's the curl I tried
curl -X GET \
'http://localhost:9200/test/default/_search?explain=' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 1bd83933-74cd-465d-87da-65bba4efcaad' \
-H 'cache-control: no-cache' \
-d '{
"from": 0,
"size": 10000,
"query": {
"bool": {
"must": [
{
"range": {
"data.createdAtEpoch": {
"from": 1589740200000,
"to": 1621318182305,
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
},
{
"bool": {
"must": [
{
"terms": {
"data.A": [
"testA"
],
"boost": 1
}
},
{
"terms": {
"data.B": [
"testB1",
"testB2",
"testB3"
],
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"version": true,
"aggregations": {
"data.payload.C": {
"terms": {
"field": "data.payload.C",
"size": 300000,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [
{
"_count": "desc"
},
{
"_key": "asc"
}
]
}
}
}
}'
I've also tried passing "explain":true
in the body and the approach here https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html. However, I get only the following result:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 0,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"data.payload.C": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": []
}
}
}
There is no explanation
. What am I doing wrong?
Upvotes: 0
Views: 492
Reputation: 16172
In the first case, you can use
GET /<index-name/_explain/<id>
This will return "matched": false
in the search result, if the document having id
did not match with the query. And if the document matches, then the score explanation (for that matched document) will come in the result.
In the second case, When you are using explain=true
, this should return the explanation of the score of all the matching documents. But, you are not getting any matched results (as the hits[]
array is empty), I think that none of the documents has matched your query due to which explain API also didn't return any result.
Upvotes: 1