Maybe something is missing for me, but the answer is no simpler than the answer. Blame?
"aggregations": { "timeslice": { "histogram": { "script": "doc['timestamp'].date.getHourOfDay()", "interval": 1, "min_doc_count": 0, "extended_bounds": { "min": 0, "max": 23 }, "order": { "_key": "desc" } } }
This is good, since it will also include any hours with zero results, and this will expand the results to cover the entire 24-hour period (due to extended_sides).
You can use 'getDayOfWeek', 'getHourOfDay', ... (see "Joda Time" for more).
This is great for a few hours, but for a few days / months it will give you a number, not a name for the month. To work, you can get the time interval as a string - but , this will not work with an extended restriction, so you may have empty results (for example, [Mon, Tue, Fri, VC]).
In case you want it, it is here:
"aggregations": { "dayOfWeek": { "terms": { "script": "doc['timestamp'].date.dayOfWeek().getAsText()", "order": { "_term": "asc" } } }
Even if this does not help you, we hope that someone else will find it and benefit from it.