Elasticsearch Composite Aggregation Orderby in Java Client 8.8.2

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

Map<String, CompositeAggregationSource> cas = new HashMap<>();
List<NamedValue<SortOrder>> orderby = new ArrayList<>();
orderby.add(NamedValue.of(key, SortOrder.Asc));

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

Can you please provide more details about the "parse exception" so that we can investigate?

[co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/search] failed: [x_content_parse_exception] [1:194] [composite] failed to parse field [sources]]

This is the exact error I'm getting in the console while running this. without order it works fine.

This is what generates using the above method.

"CompositeAggregationSource: {"terms":{"field":"KEY","order":[{"KEY":"asc"}]}}"

But it should be

"CompositeAggregationSource": { "terms": { "field": "KEY", "order": "asc" } }

Thanks. This is a known issue. We're working on it and this will be fixed in an upcoming release. Subscribe to the issue to follow resolution:

Okay. Thank you Sylvain.

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