# ES aggregation with date histogram

**URL:** <https://discuss.elastic.co/t/es-aggregation-with-date-histogram/92978>\
**Category:** Elasticsearch\
**Created:** [July 13, 2017, 9:52am UTC](https://discuss.elastic.co/t/es-aggregation-with-date-histogram/92978 "2017-07-13T09:52:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![muthuvel](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@muthuvel](https://discuss.elastic.co/u/muthuvel)\
**Post date:** [July 13, 2017, 9:52am UTC](https://discuss.elastic.co/t/es-aggregation-with-date-histogram/92978/1 "2017-07-13T09:52:33Z")

</div>

Need to filter books created by hours, The below query will return every days with hourly result.

But we need group by hours results [only.So](http://only.So) that we can able to identify peak hours.

curl [http://localhost:9002/books/\_search](http://localhost:9002/books/_search) -d '{  
"aggs" : {  
"avg books created by hour" : { "date\_histogram" : { "field" : "created\_at", "interval" : "hour"} }  
}  
}'

This query will return each & every day aggregation, But we need only 24 results .. Please let me know if possible ...

---

<div class="post-metadata">

**Author:** ![SKumarMN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skumarmn/32/27537_2.png) [@SKumarMN](https://discuss.elastic.co/u/SKumarMN)\
**Post date:** [July 13, 2017, 10:07am UTC](https://discuss.elastic.co/t/es-aggregation-with-date-histogram/92978/2 "2017-07-13T10:07:34Z")

</div>

Try regular histogram aggs

---

<div class="post-metadata">

**Author:** ![muthuvel](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@muthuvel](https://discuss.elastic.co/u/muthuvel)\
**Post date:** [July 13, 2017, 10:51am UTC](https://discuss.elastic.co/t/es-aggregation-with-date-histogram/92978/3 "2017-07-13T10:51:53Z")

</div>

While using regular histogram, we can't able to specify hourly interval..

I think can't use regular histogram, For this scenario.

---

<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:** [August 10, 2017, 10:52am UTC](https://discuss.elastic.co/t/es-aggregation-with-date-histogram/92978/4 "2017-08-10T10:52:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
