asdgvx
asdgvx

Reputation: 31

Sort root aggregations (names) in Elasticsearch query

How to sort aggregations by root names of aggregates? It seems ES is not keeping the query order of defined aggregates.

  "aggs": {
    "agg1": {
      ....
    },
    "agg2": {
      ...
    },
    "agg3": {
      ...
    }

In results, I got:

  "aggregations": {
    "agg2": {
      ....
    },
    "agg3": {
      ...
    },
    "agg1": {
      ...
    }

All topics on SO are related to sorting/ordering within the aggregate (buckets) not the root list of aggregates also official documentation is missing this part.

Upvotes: 0

Views: 47

Answers (1)

stzov
stzov

Reputation: 176

JSON objects do not guarantee order even if Elasticsearch did write them in the order you'd like.

A JSON object is an unordered collection of zero or more name/value pairs.

Upvotes: 0

Related Questions