Indexing Date Ranges

I need to index objects that have a date range associated with them (date from/to), rather than just a single date. At query time, retrieving objects that intersect a certain interval is pretty straightforward. But what I can't work out is a way to generate date histograms for my data, along the lines of the standard date histogram aggregation that works on single date fields. Any thoughts?

Maybe the following topic would be useful to you? It uses a start date and a duration but the approach could easily be modified to use a start and end date instead.

Excellent - yes that looks exactly like what I was looking for (and will help me wrap my head around scripting too :slight_smile: )

Many thanks for the quick answer!