How to perform a pipeline aggregation without returning all buckets

As question here

Using a pipeline agg. to calculate average, I dont want to return all the bucket, just the result. I dont want to use filter because there are other agg.

Your best bet is probably to use the filter_path response filtering option and just grab the parts your interested in. It's not perfect, since it will also return parts of the response you may not care about, but it'll let you trim the results a bit.

because the final query is generated. (maybe I could parse the final query and generate a filter_path.... but I think this is a very important options with pipeline agg.

You might be able to use the bucket_selector to prune out buckets you don't want, but you'll have to be careful that they are pruned after your other pipeline metrics are done being computed.

Otherwise, pipeline aggs mostly just "add" data to the results. Because pipeline aggs can operate on the results of other aggs and pipelines, and they can be chained together or multiple pipelines can operate on the same set of buckets, they only "add" to buckets otherwise they might destructively interfere with other operations. The exception is bucket_selector, so you may be able to do what you want with that.

1 Like

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