# How to get response from Serial Differencing Aggregation in java client

**URL:** <https://discuss.elastic.co/t/how-to-get-response-from-serial-differencing-aggregation-in-java-client/231338>\
**Category:** Elasticsearch\
**Created:** [May 6, 2020, 12:35pm UTC](https://discuss.elastic.co/t/how-to-get-response-from-serial-differencing-aggregation-in-java-client/231338 "2020-05-06T12:35:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![varun1992](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@varun1992](https://discuss.elastic.co/u/varun1992)\
**Post date:** [May 6, 2020, 12:35pm UTC](https://discuss.elastic.co/t/how-to-get-response-from-serial-differencing-aggregation-in-java-client/231338/1 "2020-05-06T12:35:25Z")

</div>

My aggregation code is as below, so what will be the aggregation response code?

```
RestHighLevelClient hclient = client.getClient();

SearchResponse response = hclient.search(new SearchRequest(index)
                    .source(
                            new SearchSourceBuilder()
    .query(new QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery("@timestamp").from("now-12d").to("now")))

            .aggregation(
                    AggregationBuilders.dateHistogram("mainAgg")
                                        .field("@timestamp")
                                        .dateHistogramInterval(new DateHistogramInterval("1d"))
                                        .subAggregation(AggregationBuilders.count("subAgg")
                                                .field("host.name")
                                        )
                                        .subAggregation(PipelineAggregatorBuilders.diff("diffAgg","subAgg")
                                                .lag(1)
                                        )
                        )
                .size(0)
            ), RequestOptions.DEFAULT);

    Aggregations agg = response.getAggregations();
    Histogram subterm = agg.get("mainAgg");

    for (Histogram.Bucket subEntry : subTerm.getBuckets()) {

    ValueCount count = subEntry.getAggregations().get("subAgg2");

    HOW to get Pipeline aggregation result here ??????

    }

    hclient.close();

```

How to get pipeline aggregation to result in for loop?

please help

---

<div class="post-metadata">

**Author:** ![varun1992](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@varun1992](https://discuss.elastic.co/u/varun1992)\
**Post date:** [May 13, 2020, 12:53pm UTC](https://discuss.elastic.co/t/how-to-get-response-from-serial-differencing-aggregation-in-java-client/231338/2 "2020-05-13T12:53:32Z")

</div>

Anybody please reply

---

<div class="post-metadata">

**Author:** ![varun1992](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@varun1992](https://discuss.elastic.co/u/varun1992)\
**Post date:** [May 22, 2020, 10:01am UTC](https://discuss.elastic.co/t/how-to-get-response-from-serial-differencing-aggregation-in-java-client/231338/3 "2020-05-22T10:01:35Z")

</div>

How to get responds from Serial Differencing Aggregation in java high level client Elasticsearch

---

<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:** [June 19, 2020, 10:01am UTC](https://discuss.elastic.co/t/how-to-get-response-from-serial-differencing-aggregation-in-java-client/231338/4 "2020-06-19T10:01:50Z")

</div>

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