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

**URL:** <https://discuss.elastic.co/t/java-api-unable-to-parse-response-body-for-response-at-term-suggestions-query/207255>\
**Category:** Elasticsearch\
**Created:** [November 10, 2019, 6:41pm UTC](https://discuss.elastic.co/t/java-api-unable-to-parse-response-body-for-response-at-term-suggestions-query/207255 "2019-11-10T18:41:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gustavo.lei](https://avatars.discourse-cdn.com/v4/letter/g/48db29/32.png) [@gustavo.lei](https://discuss.elastic.co/u/gustavo.lei)\
**Post date:** [November 10, 2019, 6:41pm UTC](https://discuss.elastic.co/t/java-api-unable-to-parse-response-body-for-response-at-term-suggestions-query/207255/1 "2019-11-10T18:41:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 8, 2019, 6:41pm UTC](https://discuss.elastic.co/t/java-api-unable-to-parse-response-body-for-response-at-term-suggestions-query/207255/2 "2019-12-08T18:41:17Z")

</div>

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