Parameters in Using Calculation aggregation

Can you please describe what exactly would you like to achieve there ? The current painless script will produce only 1 and 0 values for each of the buckets and it wont actually count all the documents where that expression would be true. However I don't fully understand what would you expect the average be for each document, or the standard deviation ? I think those only make sense when you are looking at buckets (multiple documents grouped together).

So at this point it looks to me this is something that you won't be able to achieve, but @simianhacker might know more ?