Elastic Search: aggregation random order?

后端 未结 3 1233
借酒劲吻你
借酒劲吻你 2021-01-27 15:21

is it possible to have aggregations with a random order? It seems that there is only asc or desc possible?

{
\"aggs\" : {
    \"genders\" : {
        \"terms\" :         


        
3条回答
  •  别那么骄傲
    2021-01-27 15:33

    Nope, according to the official documentation, terms aggregations are always sorted one way or another. If not specified, aggregated terms are sorted by count descending.

    If at all needed, you can always shuffle the results on the client-side in some random order, though.

提交回复
热议问题