Nick_M
(Nick M)
May 20, 2021, 11:52am
1
I created the query below and I want to execute it with the Java Client provided but I can't really find a way.
GET asset-records-latest/_search
{
"size": 0,
"aggs": {
"agg1": {
"terms": {
"field": "asset_id",
"order": {
"agg2": "desc"
},
"size": 10
},
"aggs": {
"agg2": {
"max": {
"field": "risk_index_value"
}
}
}
}
}
}
dadoonet
(David Pilato)
May 25, 2021, 1:33pm
2
Welcome!
What about:
SearchResponse response = client.search(new SearchRequest("asset-records-latest").source(new SearchSourceBuilder()
.size(0)
.aggregation(AggregationBuilders.terms("agg1")
.field("asset_id")
.order(BucketOrder.aggregation("agg2", false))
.subAggregation(AggregationBuilders.max("agg2").field("risk_index_value"))
)
), RequestOptions.DEFAULT);
system
(system)
Closed
June 22, 2021, 1:34pm
3
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.