Custom aggregation - mean of squared values in a time bucket


I'm trying to create a custom aggregation for buckets of time (I'm also using the date histogram) on a certain field following the formula:


Where I is all the values in the bucket of time.

I'm having a hard time calculating the mean of squared of values (mean(I.^2)). mean(I)^2 is easy to do using the avg. aggregate ES provides already.

Is there any way I could achieve this without doing the aggregation myself?

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