# Date histogram fixed interval

**URL:** https://discuss.elastic.co/t/date-histogram-fixed-interval/20451
**Category:** Elasticsearch
**Created:** [October 27, 2014, 6:18pm UTC](https://discuss.elastic.co/t/date-histogram-fixed-interval/20451 "2014-10-27T18:18:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jnortey](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@jnortey](https://discuss.elastic.co/u/jnortey)
#### Post date: [October 27, 2014, 6:18pm UTC](https://discuss.elastic.co/t/date-histogram-fixed-interval/20451/1 "2014-10-27T18:18:04Z")

</div>

Is it possible to specify a fixed interval for a date histogram  
facet/aggregation? Here is what I mean by fixed:

Lets say that I created an aggregation that returned data for between a  
certain time range. This could be for the last 24 hours, the last 30 days,  
etc. Regardless of the time range, I would like to get exactly six buckets  
of data regardless of the size of the time range.

So if the time range was for the last 24 hours, I would get a bucket for  
each four hour period. If the time range were 30 days, I would get a bucket  
for each 5 day period. Is it possible to specify something like this in the  
date time histogram?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6c0c6fcd-9f4e-4aa3-91cc-5a586f88811e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6c0c6fcd-9f4e-4aa3-91cc-5a586f88811e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [October 27, 2014, 11:42pm UTC](https://discuss.elastic.co/t/date-histogram-fixed-interval/20451/2 "2014-10-27T23:42:08Z")

</div>

Hi Jeremy,

It is not possible. One work-around could be to over request (for example  
create per-minute buckets) and finally merge them to get the desired number  
of buckets. I believe this is something that could be achieved through  
[Reducers - Post processing of aggregation results · Issue #8110 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/8110).

Another option could be to run two requests: a first one to figure the  
min/max timestamps and a second one with an interval that would generate  
the desired number of buckets.

On Mon, Oct 27, 2014 at 7:18 PM, jnortey [jeremy.nortey@gmail.com](mailto:jeremy.nortey@gmail.com) wrote:

> Is it possible to specify a fixed interval for a date histogram  
> facet/aggregation? Here is what I mean by fixed:
> 
> Lets say that I created an aggregation that returned data for between a  
> certain time range. This could be for the last 24 hours, the last 30 days,  
> etc. Regardless of the time range, I would like to get exactly six buckets  
> of data regardless of the size of the time range.
> 
> So if the time range was for the last 24 hours, I would get a bucket for  
> each four hour period. If the time range were 30 days, I would get a bucket  
> for each 5 day period. Is it possible to specify something like this in the  
> date time histogram?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/6c0c6fcd-9f4e-4aa3-91cc-5a586f88811e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6c0c6fcd-9f4e-4aa3-91cc-5a586f88811e%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/6c0c6fcd-9f4e-4aa3-91cc-5a586f88811e%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/6c0c6fcd-9f4e-4aa3-91cc-5a586f88811e%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j698OgAmvmThRcha-opcS32VNrqb9mf2s4jCvj1-JNPCA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j698OgAmvmThRcha-opcS32VNrqb9mf2s4jCvj1-JNPCA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:53am UTC](https://discuss.elastic.co/t/date-histogram-fixed-interval/20451/3 "2017-07-06T00:53:36Z")

</div>


