Ordering Significant Terms aggregation?

Hello,

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,
Arnaud

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.

HTH

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,
Arnaud

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

ok, thanks for your explanations.

Arnaud