Curious if theres a way to do Cumulative Sum on non Date/Historgram Aggregations

Question came up for one of my projects about how to calculate a cumulative sum metric on buckets outside of a Date Histogram / Histogram aggregation. Basically, if we are doing a term aggregation, is it possible to sort the buckets by some metric (like document count in each bucket) and then for each bucket include a metric that is the cumulative sum of some other metric?

Does this question make sense? Is it possible to implement this feature using scripted metrics or some other strategy? If this feature is not available in Elasticsearch, we are of course able to build the feature within the front end, but it would be great if it could be done in an Elasticsearch query itself.


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