Kibana date range aggregation by year

Hi to all,
in my use case I have an index with 2 date fields (from and to).
I'd like to be able to show the sum of all days covered by such interval aggregated by year...For example, if I have 2 docs in the form <id, from,to> like the following:

<1, 2010/01/01,2012/01/30> and
<2, 2011/01/01,2011/01/01> I would like to show

2010: 365
2011: 366
2012: 395

Is it something possible?

Best,
Flavio

Two options I can think of: (1) use Groovy in Kibana scripted fields to do date math and derive the year field; (2) index the year as a field and do aggregations based on that.

Hi Tanya,
thanks for the answer. I want to compute also the number of days for each year and aggregate that. Do you think it's possible using a scripted field?