I have a list of Buckets (parentSalaries) that has a list of Aggregations of size 2. One of the Aggregations (average_salary) has the following fields; value, name, valueAsString and metadata. I am trying to extract the data from the "value" but there is no function for it. I tried to use other types of Aggregations such as `ParsedTDigestPercentiles but there is no function that can be used to extract the "value" data. Hopefully, someone can help me.
private void doSomething(Aggregations aggregations) {
//aggregations is the Aggregations from the SearchResponse
Terms parentSalaryRatio = aggregations.get("parent_salary_ratio");
if (parentSalaryRatio != null) {
List<? extends Terms.Bucket> parentSalaries = parentSalaryRatio.getBuckets();
getTotalAvgSalaries(parentSalaries);
}
}
private void getTotalAvgSalaries(List<? extends Terms.Bucket> parentSalaries) {
Aggregations aggregations = parentSalaries.get(0).getAggregations();
Aggregation avgSalaryAgg = aggregations.get("avg_salary");
//No function to get the "value" out of "avgSalaryAgg"
}
Query
AggregationBuilder precentials_salary = AggregationBuilders
.percentiles("precentials_salary")
.field("perAnnumSalary");
AggregationBuilder average_salary = AggregationBuilders
.avg("average_salary")
.field("perAnnumSalary");
Thanks