Sum one or more fields with date aggregation

Hi all,

can you please help me on this. I have this following data:

  1. timestamp: 2018-01-01T10:30:00+08:00 , countSubject : 3 , countExtra: 5
  2. timestamp: 2018-01-11T10:30:00+08:00 , countSubject : 4 , countExtra: 5
  3. timestamp: 2018-03-01T10:30:00+08:00 , countSubject : 6 , countExtra: 5
  4. timestamp: 2018-02-29T10:30:00+08:00 , countSubject : 8 , countExtra: 5

I just want to clarify if I can have a query that gets the sum of countSubject, sum of countExtra from 2018-01-01 to 2018-05-01 with monthly interval

Yep. Use a date_histogram aggregation on the timestamp field, with a monthly interval. Then add a sum aggregation for each of the two fields.

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