user4786325
user4786325

Reputation: 21

Scripted Metric Aggregation order

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": {
            ...
          }
        }
      }
    }
  }

Upvotes: 2

Views: 2014

Answers (1)

justinsAccount
justinsAccount

Reputation: 751

Nope, it's a current limitation. Being tracked in https://github.com/elastic/elasticsearch/issues/8486

Upvotes: 3

Related Questions