Elasticsearch Composite Aggregation Orderby in Java Client 8.8.2

I'm getting a parse exception when I add order to CompositeAggregationSource.

List<Map<String, CompositeAggregationSource>> casList = new ArrayList<>();

for (int i = 0; i < groupBy.size(); i++) {
  Map<String, CompositeAggregationSource> cas = new HashMap<>();
  String key = groupBy.get(i);

  List<NamedValue<SortOrder>> orderby = new ArrayList<>();
  sortingList.stream().forEach(sortingDto -> {
    if (sortingDto.getOrderBy().equals("ASC")) {
      orderby.add(NamedValue.of(key, SortOrder.Asc));
    } else {
      orderby.add(NamedValue.of(key, SortOrder.Desc));
    }

    cas.put(key,
        CompositeAggregationSource.of(
            c -> c.terms(t -> t.field(key).order(orderby))));
  });

  casList.add(i, cas);
}

I'm getting the following exception

"[es/search] failed: [x_content_parse_exception] [1:445] [composite] failed to parse field [sources]"

Hello! This was a bug we had involving the order field that was fixed in most recent versions, updating the java client should solve this.

2 Likes

Thank you