# Pipeline Aggregation for Date histrogram with terms in Java, elastic 6.6

**URL:** <https://discuss.elastic.co/t/pipeline-aggregation-for-date-histrogram-with-terms-in-java-elastic-6-6/209828>\
**Category:** Elasticsearch\
**Created:** [November 28, 2019, 10:20am UTC](https://discuss.elastic.co/t/pipeline-aggregation-for-date-histrogram-with-terms-in-java-elastic-6-6/209828 "2019-11-28T10:20:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SRI\_SUSHMA\_Karra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sri_sushma_karra/32/49309_2.png) [@SRI\_SUSHMA\_Karra](https://discuss.elastic.co/u/SRI_SUSHMA_Karra)\
**Post date:** [November 28, 2019, 10:20am UTC](https://discuss.elastic.co/t/pipeline-aggregation-for-date-histrogram-with-terms-in-java-elastic-6-6/209828/1 "2019-11-28T10:20:37Z")

</div>

Hi,

I am kind of struugling with coming up with a Java equivalent to the solution posted here.

> [@Pipeline aggregation: date histogram + terms](https://discuss.elastic.co/t/pipeline-aggregation-date-histogram-terms/68067):
>
> Hi, I would like to dynamically build fixed size buckets over the dates (date\_histogram). Then, for every date range, I would like buckets dynamically built one per term. So the result would be something like that: [{ "timestamp": "month0", "tags": ["blue": 41, "red": 35, "green": 21] }, ... { "timestamp": "monthN", "tags": ["blue": 41, "red": 35, "green": 21] }, ] In order to achieve that I did the following pip…

```
AggregationBuilders.global("global_aggregation")
		.subAggregation(AggregationBuilders.dateHistogram("dateAggr")
        .field("IngestedTime").dateHistogramInterval(DateHistogramInterval.DAY).timeZone(dt)
        .subAggregation(PipelineAggregatorBuilders. // how do I include the terms here?)

```

---

<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:** [December 26, 2019, 10:20am UTC](https://discuss.elastic.co/t/pipeline-aggregation-for-date-histrogram-with-terms-in-java-elastic-6-6/209828/2 "2019-12-26T10:20:39Z")

</div>

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