# Troubleshooting for query

**URL:** https://discuss.elastic.co/t/troubleshooting-for-query/205017
**Category:** Elasticsearch
**Created:** [October 24, 2019, 8:26am UTC](https://discuss.elastic.co/t/troubleshooting-for-query/205017 "2019-10-24T08:26:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Nee\_Defeng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nee_defeng/32/45771_2.png) [@Nee\_Defeng](https://discuss.elastic.co/u/Nee_Defeng)
#### Post date: [October 24, 2019, 8:26am UTC](https://discuss.elastic.co/t/troubleshooting-for-query/205017/1 "2019-10-24T08:26:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)
#### Post date: [October 25, 2019, 3:31pm UTC](https://discuss.elastic.co/t/troubleshooting-for-query/205017/2 "2019-10-25T15:31:51Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html):

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

---

<div class="post-metadata">

### Author: ![Nee\_Defeng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nee_defeng/32/45771_2.png) [@Nee\_Defeng](https://discuss.elastic.co/u/Nee_Defeng)
#### Post date: [October 26, 2019, 12:06pm UTC](https://discuss.elastic.co/t/troubleshooting-for-query/205017/3 "2019-10-26T12:06:59Z")

</div>

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" :   
}  
]  
}  
]  
}  
]  
}  
}

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 23, 2019, 12:07pm UTC](https://discuss.elastic.co/t/troubleshooting-for-query/205017/4 "2019-11-23T12:07:13Z")

</div>

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