2
votes

In elasticsearch 1.5.0, I try to sort/order the aggregation bucket using scripted_metric result,but receive bellow error:

AggregationExecutionException[Invalid terms aggregation order path [custom_script]. Terms buckets can only be sorted on a sub-aggregator path that is built out of zero or more single-bucket aggregations within the path and a final single-bucket or a metrics aggregation at the path end

is any way to solve this issue?

my query like this:

"aggs": {
    "mygroup": {
      "terms": {
        "field": "customername",
        "order": {
          "custom_script": "asc"
        }
      },
      "aggs": {
        "custom_script": {
          "scripted_metric": {
            ...
          }
        }
      }
    }
  }
1

1 Answers

3
votes