# Using missing\_bucket with a composite aggregation with a date\_histogram source doesn't seem to create missing buckets

**URL:** <https://discuss.elastic.co/t/using-missing-bucket-with-a-composite-aggregation-with-a-date-histogram-source-doesnt-seem-to-create-missing-buckets/243635>\
**Category:** Elasticsearch\
**Created:** [August 4, 2020, 1:59am UTC](https://discuss.elastic.co/t/using-missing-bucket-with-a-composite-aggregation-with-a-date-histogram-source-doesnt-seem-to-create-missing-buckets/243635 "2020-08-04T01:59:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![acommend](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@acommend](https://discuss.elastic.co/u/acommend)\
**Post date:** [August 4, 2020, 1:59am UTC](https://discuss.elastic.co/t/using-missing-bucket-with-a-composite-aggregation-with-a-date-histogram-source-doesnt-seem-to-create-missing-buckets/243635/1 "2020-08-04T01:59:44Z")

</div>

Using missing\_bucket with a composite aggregation with a date\_histogram source doesn't seem to create missing buckets. In the example below, 2 documents are created with a date field that are 45 minutes apart. Using a composite aggregation date\_histogram source with a fixed\_interval set to 15m the expected outcome should be 3 buckets, one for each 15 minute interval with the interval in the middle containing 0 doc\_count. Instead only the first and last 15 minute intervals are present in the response. Please review my example to confirm the bug.

Enter the following in a Kibana console to reproduce the problem:

1. Create index with date mapping for time field

```auto
PUT /test
{
  "mappings": {
    "properties": {
      "myDate": { "type": "date" }
    }
  }
}

```

1. Add test data

```auto
PUT /test/_doc/1
{
  "myDate": "2020-08-03T15:00:00"
}

PUT /test/_doc/2
{
  "myDate": "2020-08-03T15:45:00"
}

```

1. Create composite aggregation with date histogram with 15 minute intervals

```auto
GET /test/_search
{
  "size": 0,
  "query": {
    "match_all": {}
  },
  "aggregations": {
    "intervals": {
      "composite": {
        "sources": [
          {
            "test_date_histogram": {
              "date_histogram": {
                "field": "myDate",
                "fixed_interval": "15m",
                "missing_bucket": true
              }
            }
          }
        ]
      }
    }
  }
}

```

Response from Kibana console:

```auto
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  },
  "aggregations" : {
    "intervals" : {
      "after_key" : {
        "test_date_histogram" : 1596469500000
      },
      "buckets" : [
        {
          "key" : {
            "test_date_histogram" : 1596466800000
          },
          "doc_count" : 1
        },
        {
          "key" : {
            "test_date_histogram" : 1596469500000
          },
          "doc_count" : 1
        }
      ]
    }
  }
}

```

Elasticsearch/Kibana version: 7.4.2  
Java version: openjdk version "12.0.2" 2019-07-16  
OS version: Windows 10 Professional

---

<div class="post-metadata">

**Author:** ![acommend](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@acommend](https://discuss.elastic.co/u/acommend)\
**Post date:** [August 10, 2020, 6:21pm UTC](https://discuss.elastic.co/t/using-missing-bucket-with-a-composite-aggregation-with-a-date-histogram-source-doesnt-seem-to-create-missing-buckets/243635/2 "2020-08-10T18:21:24Z")

</div>

Tried the same example with the same result in Elasticsearch/Kibana version 7.8.1

---

<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:** [September 7, 2020, 6:21pm UTC](https://discuss.elastic.co/t/using-missing-bucket-with-a-composite-aggregation-with-a-date-histogram-source-doesnt-seem-to-create-missing-buckets/243635/3 "2020-09-07T18:21:31Z")

</div>

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