I have a Composite Aggregation query executing locally on ElasticSearch Version 6.4.2 using the Java High Level Rest Client. The query runs fine and the result is same as when running the query on Kibana console.
However, When I run the same code against ElasticSearch Version 6.3.2 hosted on AWS it returns a bad request with the following error:
{
"error": {
"root_cause": [
{
"type": "x_content_parse_exception",
"reason": "[1:171] [composite] failed to parse field [sources]"
}
],
"type": "x_content_parse_exception",
"reason": "[1:171] [composite] failed to parse field [sources]",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "[terms] unknown field [missing_bucket], parser not found"
}
},
"status": 400
}
Java Code:
private void query(LocalDate date, Map<String, Object> afterKey) {
String inViewIndex = "a";
String loadIndex = "b";
SearchRequest request = new SearchRequest(inViewIndex, loadIndex);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.size(0);
searchSourceBuilder.trackTotalHits(false);
List<CompositeValuesSourceBuilder<?>> sources = new ArrayList<>();
TermsValuesSourceBuilder account = new TermsValuesSourceBuilder("account_split")
.field("account");
sources.add(account);
TermsAggregationBuilder aggregation = AggregationBuilders.terms("index_split").field("_index");
CompositeAggregationBuilder compositeAggregationBuilder =
new CompositeAggregationBuilder("aggregate_buckets", sources);
compositeAggregationBuilder.subAggregation(aggregation);
compositeAggregationBuilder.size(1000);
if (afterKey.size() > 0) {
compositeAggregationBuilder.aggregateAfter(afterKey);
}
searchSourceBuilder.aggregation(compositeAggregationBuilder);
request.source(searchSourceBuilder);
SearchResponse searchResponse = executeCompositeAggregation(request);
}
Is the ElasticSearch Version incapable of handling this request through the Java Rest Client since the same query works through the Kibana console?
The current work around we have is to use the Java Low Level Client to fire the query and process the response manually but the preferable solution would be to use Java High Level Rest Client.
Any help would be greatly appreciated!
Thanks