# Merging buckets of aggregation

**URL:** <https://discuss.elastic.co/t/merging-buckets-of-aggregation/191887>\
**Category:** Elasticsearch\
**Created:** [July 23, 2019, 6:07pm UTC](https://discuss.elastic.co/t/merging-buckets-of-aggregation/191887 "2019-07-23T18:07:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hari\_Prasad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hari_prasad/32/56784_2.png) [@Hari\_Prasad](https://discuss.elastic.co/u/Hari_Prasad)\
**Post date:** [July 23, 2019, 6:07pm UTC](https://discuss.elastic.co/t/merging-buckets-of-aggregation/191887/1 "2019-07-23T18:07:15Z")

</div>

I am trying to merge buckets from a parent aggregation. I am not sure if thats possible. Please help.

I have an aggregation query as below

```
GET log-2019.07.20/_search
{
  "size": 0,
  "aggs": {
    "buckets": {
      "date_histogram": {
        "field": "@timestamp",
        "interval": "5m",
        "format": "mm"
      }
    }
  }
}

```

and the output is like

```
.
.
.
"aggregations" : {
    "buckets" : {
      "buckets" : [
        {
          "key_as_string" : "00",
          "key" : 1563840000000,
          "doc_count" : 3535
        },
        {
          "key_as_string" : "05",
          "key" : 1563840300000,
          "doc_count" : 3556
        },
.
.
.

```

What I am trying to do is run a term aggregation on the **key\_as\_string** field but its always showing empty bucket.

Is there any way to combine buckets ??

Thank you

---

<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 20, 2019, 6:07pm UTC](https://discuss.elastic.co/t/merging-buckets-of-aggregation/191887/2 "2019-08-20T18:07:21Z")

</div>

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