Java API - "Unable to parse response body for Response"at term suggestions query

I'm trying to use implement Elasticsearch terms suggestions query using Java High Level Rest Client but going some issues. Some important information:

  • I'm using jdk8
  • I'm using the latest version of java api (7.4)
  • Any other query I've tried (search, index) works fine

This is the exception being throw when fetching the results of my term suggestions query:

java.io.IOException: Unable to parse response body for Response{requestLine=POST /_search?typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&ignore_throttled=true&search_type=query_then_fetch&batched_reduce_size=512&ccs_minimize_roundtrips=true HTTP/1.1, host=http://localhost:9200, response=HTTP/1.1 200 OK}

My code is pretty much what I've got from Elasticsearch official guide:

SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
SuggestionBuilder termSuggestionBuilder =
SuggestBuilders.termSuggestion("name").text(wrongCommand);
SuggestBuilder suggestBuilder = new SuggestBuilder();
suggestBuilder.addSuggestion("suggest_user", termSuggestionBuilder);
searchSourceBuilder.suggest(suggestBuilder);

ElasticSearchService.getInstance().searchAsync(COMMAND_TOPIC_NAME, searchSourceBuilder, listener);

For the searchAsync body:

 SearchRequest searchRequest = new SearchRequest();  
 searchRequest.source(query);
        
        
  client.searchAsync(searchRequest, RequestOptions.DEFAULT, listener);

In case you need information about my index configuration, here's how it is built:

builder = XContentFactory.jsonBuilder();
 builder.startObject();
 {
        builder.startObject("properties");
        {
              builder.startObject("helpExample");
              {
                    builder.field("type", "text");
              }
              builder.endObject();

           builder.startObject("descritpion");
           {
                 builder.field("type", "text");
           }
           builder.endObject();
                    
           builder.startObject("type");
           {
                 builder.field("type", "text");
           }
           builder.endObject();
                    
           builder.startObject("name");
           {
                 builder.field("type", "text");
           }
           builder.endObject();

             builder.startObject("topic");
             {
                   builder.field("type", "text");
             }
             builder.endObject();
   }
   builder.endObject();

}

What I've tried so far?

  • Doing some research I found that could be about some HTTP size request limit, but I don't believe could be this, since my index has a total of 29 documents. I tried to update the max value anyways but the result looks the same.
  • I tried checking if my .jars of elastic search is all at the same version (they all look to be at version 7.4). Any of them that I should double check?

Is there any way to debug the body of the response of my query?

Any help is appreciated.

Thank you for your attention.

1 Like

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