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.