# How to sort on '\_explanation' from query search

**URL:** <https://discuss.elastic.co/t/how-to-sort-on-explanation-from-query-search/124350>\
**Category:** Elasticsearch\
**Created:** [March 16, 2018, 6:20pm UTC](https://discuss.elastic.co/t/how-to-sort-on-explanation-from-query-search/124350 "2018-03-16T18:20:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JustinChavez](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@JustinChavez](https://discuss.elastic.co/u/JustinChavez)\
**Post date:** [March 16, 2018, 6:20pm UTC](https://discuss.elastic.co/t/how-to-sort-on-explanation-from-query-search/124350/1 "2018-03-16T18:20:33Z")

</div>

I am trying to sort on the '\_explanation' field returned from my search query. Elasticsearch is not finding the field and is sorting on infinity instead. I was wondering if there is a solution for this?

results = es.search(index="index", size=50, body={'explain':True,'query': {"function\_score": {  
"query": {  
'bool': {'should': [  
{'constant\_score': {'filter': {'multi\_match': {'query': 'hello', "fields":['field1','field2']}}}}]}  
},  
"functions": [{  
"field\_value\_factor": {  
"field": "field3",  
"factor": 1  
}  
},  
{"field\_value\_factor": {  
"field": "field4",  
"factor": 1  
}}  
],  
"score\_mode": "sum",  
"boost\_mode": "replace"  
}  
},

```
                                           'sort': [{'_explanation.value':{"order":"desc","unmapped_type":"float"}}]
                                           , "track_scores":True})
```

---

<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:** [April 13, 2018, 6:20pm UTC](https://discuss.elastic.co/t/how-to-sort-on-explanation-from-query-search/124350/2 "2018-04-13T18:20:37Z")

</div>

Closed on April 13, 2018, 6:20pm UTC

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