Are ScriptedMetric aggregations compatible with Pipeline Aggregations?

I have a histogram aggregation that returns n documents per bucket that I was then computing an Average sub aggregation on and then finally doing a pipeline aggregation of all the bucket averages. This was working great, but I wanted to change it so I could compute the average on the "largest 4" values in each histogram bucket. I wrote a scripted metric that now does this wonderfully, however my pipeline aggregation now complains with the following error:

buckets_path must reference either a number value or a single value numeric metric aggregation, got: org.elasticsearch.search.aggregations.metrics.scripted.InternalScriptedMetric

Sample output from my scripted metric:

aggregations": {
      "by_vehicle_number": {
        "doc_count_error_upper_bound": 0,
        "sum_other_doc_count": 0,
        "buckets": [
          {
            "key": 26,
            "doc_count": 174,
            "samples": {
              "buckets": [
                {
                  "key": 1485254085512,
                  "doc_count": 12,
                  "avg_cno": {
                    "value": 41.666666666666664
                  }
                },
                {
                  "key": 1485254086514,
                  "doc_count": 12,
                  "avg_cno": {
                    "value": 42.5
                  }
                }]
            }
          }
        ]
      }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.