1

Given a term aggregation (label), I would like to sort the bucket by a string field (energy).

The problem is that we cannot use a multi-bucket value in the order clause.

For a given label, I'm sure that there is only one energy. What I would like to do is to use the first (and only) result of my energy sub aggregation.

I'm using the AWS elasticsearch service which is in a 1.5 version, and scripts are disabled, so I did not find a way to sort the bucket by another term :(

{
  "aggs" : {
    "label" : {
      "terms" : { "field" : "label" },
      "order" : { "energy[0]" : "desc" } // cannot do this
    },
    "aggs" : {
      "energy" : {
         "terms" : {
            "field" : "energy",
            "size" : 1
          }
      }
    }
  }
}
Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
anthofo
  • 93
  • 12

0 Answers0