Get number of days in a month to aggregate data

@spinscale Thanks Alex, I figure out what I am missing. Since I set the size as 0 (I use result in aggregation only) so that scripted field is missing. After set the size as 1, it comes back as expected.

In aggregation part, I group data daily in a month. I already have the _source.month_price so scripted field above is for division to get daily price. After that, I will multiply the field extra_usage with the daily_price to have daily daily charge. That is what I am after.

However, scripted field is not able to be reused in aggregation. Hence, there will be duplicate calculation for the value of the scrpited field if I put the whole script (get days of a month) in aggregation.

Maybe I have to do it in the client side. :slight_smile:

Cheers!