# Aggregations: Irregular timebased buckets, possible?

**URL:** <https://discuss.elastic.co/t/aggregations-irregular-timebased-buckets-possible/34500>\
**Category:** Elasticsearch\
**Created:** [November 13, 2015, 10:37am UTC](https://discuss.elastic.co/t/aggregations-irregular-timebased-buckets-possible/34500 "2015-11-13T10:37:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![edwardsmit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/edwardsmit/32/5894_2.png) [@edwardsmit](https://discuss.elastic.co/u/edwardsmit)\
**Post date:** [November 13, 2015, 10:37am UTC](https://discuss.elastic.co/t/aggregations-irregular-timebased-buckets-possible/34500/1 "2015-11-13T10:37:27Z")

</div>

I would like to accomplish that some time-based events get grouped in buckets of **5m** (minutes) each and that the key of the bucket is the **minimum value** in that bucket. When I use a `date_histogram` aggregation with an `interval` of `5m` I get buckets that are aligned on 5m periods even when the lowest value in that bucket is larger. So using 5m buckets and the **values 21m, 26m, and 44m** I would like to have a bucket **starting at 21m** with two values and one bucket at 44m with one value.  
Gist: [https://gist.github.com/edwardsmit/0a0a3f12f87e5f6eb3a7](https://gist.github.com/edwardsmit/0a0a3f12f87e5f6eb3a7)  
I'm trying to set the `min` of a `date_histogram` to the `min` as found by stats, but I'm unsuccesfull up till know.  
Is this even possible, or does anybody know a way to accomplish what I'm trying to do?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:38pm UTC](https://discuss.elastic.co/t/aggregations-irregular-timebased-buckets-possible/34500/2 "2017-07-05T23:38:40Z")

</div>

Closed on July 5, 2017, 11:38pm UTC


