Troubleshooting for query

Hi guys,

Just wondering how you guys will find out the reason if one query does not return the result as expected? I know you can use 'explain' api to find out how the match score is calculated, but how can I use this if that document does not show up in the query?

I have tried to use min_score but it seems like it is for a different purpose.

Please help to point out where it is documented, and if it is not in place, may I request to add this somewhere in the online documentation? I thought it would be a general question for everybody.

You can use the Explain API by hitting _explain on a specific document. That will tell you exactly why that specific document does not match or has a much lower score that you may have expected. The documentation has an example:

GET /twitter/_explain/0
{
      "query" : {
        "match" : { "message" : "elasticsearch" }
      }
}

That example will explain exactly what would happen for that given query on document 0 in the twitter index.

1 Like

Exactly, here is my example:

GET /myfirstfsjob/_explain/c6ddcbd625ebb66c85d5e299a21bdda7
{
    "query": {
        "function_score": {
            "query": { "match_all": {} },
            "boost": "5",
            "random_score": {}, 
            "boost_mode":"multiply",
            "min_score" : 42
        }
    }
}

And here is the output:

{

"_index" : "myfirstfsjob",
"_type" : "_doc",
"_id" : "c6ddcbd625ebb66c85d5e299a21bdda7",
"matched" : false,
"explanation" : {
"value" : 0.0,
"description" : "Score value is too low, expected at least 42.0 but got 4.5719132",
"details" : [
{
"value" : 4.5719132,
"description" : "function score, product of:",
"details" : [
{
"value" : 5.0,
"description" : ":^5.0",
"details" :
},
{
"value" : 0.91438264,
"description" : "min of:",
"details" : [
{
"value" : 0.91438264,
"description" : "random score function (seed: 133470742, field: null)",
"details" :
},
{
"value" : 3.4028235E38,
"description" : "maxBoost",
"details" :
}
]
}
]
}
]
}
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.