Relative date in range filter

Hello guy,

Can i take dates from date histogram bucket and use it in query time?

For example, i have docs:
{ "date1": "2015-10-01", "date2": "2015-10-15", "date3": "2015-10-12" }
{ "date1": "2015-10-02", "date2": "2015-10-18", "date3": "2015-10-11" }
{ "date1": "2015-10-03", "date2": "2015-10-18", "date3": "2015-10-04" }
...

I want to draw table where rows is date histogram by date1 field.

  • First col - date1
  • Second col - count of date2 field in range "date1 + 1 day"
  • Third col - count of date2 field in range "date1 + 2 day"

Right now i have just solution: programmatically calculate rows and do query (or aggregation) for each row.

P.S. i broke my head already :).