Composite Aggregation Query Fails On ElasticSearch 6.3.2

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();  
        List<CompositeValuesSourceBuilder<?>> sources = new ArrayList<>();  
        TermsValuesSourceBuilder account = new TermsValuesSourceBuilder("account_split")  
        TermsAggregationBuilder aggregation = AggregationBuilders.terms("index_split").field("_index");  
        CompositeAggregationBuilder compositeAggregationBuilder =  
                new CompositeAggregationBuilder("aggregate_buckets", sources);  
        if (afterKey.size() > 0) {  
        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!

I think, you are using wrong version of elasticsearch-rest-high-level-client library in your client. Try to change version to 6.3.2. ElasticSearch Server dosn't support missing_bucket for this aggregation in version 6.3.2.

1 Like

That was the issue, updating the rest client version solved the problem.

Thanks a lot Alexander.

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