# Date histogram for Bucket Aggregation

**URL:** <https://discuss.elastic.co/t/date-histogram-for-bucket-aggregation/284592>\
**Category:** Elasticsearch\
**Created:** [September 20, 2021, 5:43am UTC](https://discuss.elastic.co/t/date-histogram-for-bucket-aggregation/284592 "2021-09-20T05:43:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manisekhar\_techo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manisekhar_techo/32/78185_2.png) [@Manisekhar\_techo](https://discuss.elastic.co/u/Manisekhar_techo)\
**Post date:** [September 20, 2021, 5:43am UTC](https://discuss.elastic.co/t/date-histogram-for-bucket-aggregation/284592/1 "2021-09-20T05:43:07Z")

</div>

Hi,  
I have a terms bucket aggregation on a field. is there a way to get the date histogram for each of the listed Bucket items received from terms aggregation.

Something like this. this isn't working but just to give the reference

```auto
{
    "query": {
        "bool": {
            "must": [ 
               SAMPLE_QUERY
            ]
        }
    },
    "aggs": {
        "category": {
            "terms": {
                "field": "category",
                "size": 200
            },
            "aggs": {
                "dates": {
                    "date_histogram":{
                        "field": "date",
                        "interval": "year",
                        "format": "yyyy"
                    }
                }
            }
        }
    }
}

```

from this, I'm expecting the Date histogram for each of the Bucket items that'll be returned.

Any suggestion will help greatly.

Thanks.

---

<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:** [October 18, 2021, 5:43am UTC](https://discuss.elastic.co/t/date-histogram-for-bucket-aggregation/284592/2 "2021-10-18T05:43:45Z")

</div>

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