Ordering Significant Terms aggregation?

(Arnaud Cassaigne) #1


I'd like to order the results of a Significant Terms aggregation by descending count.

It is possible to specify: "order": { "_count" : "desc" } for a Terms aggregation but the key "order" is not recognized for a Significant Terms aggregation.

Any ideas ?

Best regards,

(Colin Goodheart-Smithe) #2

The Significant Terms aggregation does not currently have the ability to define order, the buckets are returned in order of descending significance score. If you would like to see this feature I would suggest raising an issue on the issue list of the Elasticearch Github repository or if you fancy having a go at implementing the feature yourself and contributing it back to the project, raise a Pull Request with your code changes.


(Arnaud Cassaigne) #3

Hello Colin,

thanks for your response ! It confirms what I expected.

Do you think there is a workaround ? Something like having a ES query with two nested levels: first the Significant Terms aggregation and then the ordering ?

Thank you,

(Colin Goodheart-Smithe) #4

The only workaround would be to retrieve the buckets in your application and perform the sorting there.

(Arnaud Cassaigne) #5

ok, thanks for your explanations.


(system) #6