Can not extract the "value" from the Aggregation

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();

 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"



 AggregationBuilder precentials_salary = AggregationBuilders
    AggregationBuilder average_salary = AggregationBuilders


Welcome to our community! :smiley:

It'd be great if you could share your query and an example response so people can see exactly what you are referring to.

Hi Mark,

I updated the question. Hope it helps.


I used ParsedSingleValueNumericMetricsAggregation to extract the "value" data. It has the value() function. The ParsedAvg can be used as well. It extends ParsedSingleValueNumericMetricsAggregation

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