# Elasticsearch date-histogram aggregations default buckets

**URL:** <https://discuss.elastic.co/t/elasticsearch-date-histogram-aggregations-default-buckets/235757>\
**Category:** Elasticsearch\
**Created:** [June 4, 2020, 12:49pm UTC](https://discuss.elastic.co/t/elasticsearch-date-histogram-aggregations-default-buckets/235757 "2020-06-04T12:49:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GuyMoses](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@GuyMoses](https://discuss.elastic.co/u/GuyMoses)\
**Post date:** [June 4, 2020, 12:49pm UTC](https://discuss.elastic.co/t/elasticsearch-date-histogram-aggregations-default-buckets/235757/1 "2020-06-04T12:49:32Z")

</div>

I am using elastic search's date\_histogram to retrieve data  
my query looks as follows:

POST

```auto
{
  "size": 0,
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "@timestamp",
        "interval": "1h"
      }
    }
  },
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "@timestamp": {
              "format": "strict_date_optional_time",
              "gte": "2020-06-04T07:00:01.185Z",
              "lte": "2020-06-04T14:57:01.185Z"
            }
          }
        }
      ]
    }
  }
}

```

But I'm only getting 1 bucket as a result.

```auto
"buckets": [
                {
                    "key_as_string": "2020-06-04T09:00:00.000Z",
                    "key": 1591261200000,
                    "doc_count": 7
                }
            ]

```

I wish to get also empty buckets for all of the intervals where I have 0 docs.  
Is it possible? or do I have to fill those buckets with 0 myself?  
Thanks,

Guy

---

<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 2, 2020, 12:49pm UTC](https://discuss.elastic.co/t/elasticsearch-date-histogram-aggregations-default-buckets/235757/2 "2020-07-02T12:49:34Z")

</div>

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