Aggregation score and decay

(kevins) #1

When calculating an average for a field in the documents using an aggregation we typically create a date range filter. I am curious to know if it is possible to construct an aggregation using a custom score with a decay.

e.g. give me the average and use the data from:
now to now-1w (score 1) +
now-1w to now-2w (score 0.5 w decay) +

Is this possible? I use a method now that simply does multiple queries and builds my own weighted average and would prefer a better method.

(Colin Goodheart-Smithe) #2

If I understand what you are trying to do correctly, I think you might be looking for the moving average pipeline aggregation which was released in 2.0:

Hope that helps

(system) #3