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