# Histogram Aggregation: With minimum doc count and extended bounds

**URL:** <https://discuss.elastic.co/t/histogram-aggregation-with-minimum-doc-count-and-extended-bounds/58495>\
**Category:** Elasticsearch\
**Created:** [August 20, 2016, 12:36am UTC](https://discuss.elastic.co/t/histogram-aggregation-with-minimum-doc-count-and-extended-bounds/58495 "2016-08-20T00:36:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark2](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@mark2](https://discuss.elastic.co/u/mark2)\
**Post date:** [August 20, 2016, 12:36am UTC](https://discuss.elastic.co/t/histogram-aggregation-with-minimum-doc-count-and-extended-bounds/58495/1 "2016-08-20T00:36:17Z")

</div>

Hi There,  
I'm running ES 2.3.3 and have a question regarding Date Histograms with min doc count and extended bounds. I would like to return all buckets within a given date range (e.g. one month) including buckets with no values with a value of 0. (for ease of graphing)

The following query works correctly, however it does not filter the results to within the date range of 2016-08-01 and 2016-08-02. My understanding from reading the docs is the filter should restrict the result set to be within the bounds of the range queries. I have tried with both a query and a date range filter. The buckets for the past year keep coming through, instead of for just the date range specified.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html#search-aggregations-bucket-histogram-aggregation-extended-bounds](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html#search-aggregations-bucket-histogram-aggregation-extended-bounds)

![](https://us1.discourse-cdn.com/elastic/original/2X/f/fad7cb64e10653eaa86677244fb6f3d6b61ede46.png)

Also, if I remove the extended bounds I only receive the buckets with non-zero values which is also not what I am looking for: min doc count=0 buckets should also be included.

![](https://us1.discourse-cdn.com/elastic/original/2X/b/bfbaf82dc78842c0ca2ef95a028e3289e4ac12de.png)

---

<div class="post-metadata">

**Author:** ![mark2](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@mark2](https://discuss.elastic.co/u/mark2)\
**Post date:** [September 19, 2016, 5:51am UTC](https://discuss.elastic.co/t/histogram-aggregation-with-minimum-doc-count-and-extended-bounds/58495/2 "2016-09-19T05:51:58Z")

</div>

The API is buggy. "_For filtering buckets, one should nest the histogram aggregation under a range filter aggregation with the appropriate from/to settings._" This does not not work as documented.

---

<div class="post-metadata">

**Author:** ![mainec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mainec/32/5557_2.png) [@mainec](https://discuss.elastic.co/u/mainec)\
**Post date:** [September 19, 2016, 12:06pm UTC](https://discuss.elastic.co/t/histogram-aggregation-with-minimum-doc-count-and-extended-bounds/58495/3 "2016-09-19T12:06:16Z")

</div>

Would you mind filing a Github issue for that in case you haven't already done so?

---

<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, 10:19pm UTC](https://discuss.elastic.co/t/histogram-aggregation-with-minimum-doc-count-and-extended-bounds/58495/4 "2017-07-05T22:19:15Z")

</div>


