Sort on nested aggreagations


(Magdalena) #1

I have nested mapping and doing nested aggregations on it. I would like to sort by the most inner value - sum_num_transactions in this case. How can I achieve it? I have expected that on .nested(name, "breakdown") will be available something like:
.order(BucketOrder.aggregation("sum_num_transactions", true))
but it is not there for nested (only for terms) . How can I sort on sum_num_transactions?

  private NestedAggregationBuilder buildNestedAggregations(String name) {
            return AggregationBuilders.nested(name, "breakdown")
                    .subAggregation(
                            AggregationBuilders
                                    .sum("sum_num_transactions").field("breakdown.num_transactions")
                    )
                   .subAggregation(
                            AggregationBuilders
                                  .sum("sum_commission_amount_in_cents").field("breakdown.commission_amount_in_cents")
                    );
        }

(system) #2

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