Top hit aggregation with _score sorting


(Tom Sharp) #1

Hi,

Is there a way to do a top hit aggregation ordering the buckets by max document score?

I saw you can do it using the script sorting ie: http://stackoverflow.com/questions/26213271/elasticsearch-aggregation-order-by-top-hit-score

But I don't have access to scripting for some reason.. Any clue ?


#2

I don't see an exact example and hence unable to give the right DSL but does the following construct work:

{
"query":{
"bool":{
"should":[

     ]
  }

},
"aggs":{
"group_by_score: {
"terms":{
"field":"search_field"
},
"aggs":{
"score":{
"max":{
"field":"_score"
}
}
}
}
}


(Tom Sharp) #3

Hi polya,

No it doesn't work. In the response it says "sort': [None]" - I assume it is because _score is not really a field. I launched a new instance and this seems to work as I want but uses scripts.


(system) #4