RestHighLevelClient - Unable to parse response body

I'm new to ES and wiring up my first sample in a Java Spring Boot app. I'm using the pure
RestHighLevelClient approach but seem to keep getting a Unable to parse response body message when I call the client.

I'm a bit stuck on how to populate SearchResponse, any thoughts on how to troubleshoot?

// Config class

    public RestHighLevelClient client() {
        return new RestHighLevelClient(RestClient.builder(new HttpHost(hostUrl, port, scheme)));
// Proxy class

    public List<ResidentModel> getInitialSample() {

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(QueryBuilders.termQuery("first_name", "john"));
        SearchRequest searchRequest = new SearchRequest(new String[] {"myresidents"}, searchSourceBuilder);

        SearchResponse searchResponse = null;
            searchResponse =, RequestOptions.DEFAULT);
        }catch (ElasticsearchException ex){
            SearchHits hits = searchResponse.getHits();
        return null;        // still need to deserialize the response.

I figured it out. Elastic was installed on a Kubernetes cluster I was trying to hit and the NginX ingress controller was not configured with SSL but had the following flag set trying to redirect access. "true"

So if you get a "Unable to parse response body" message (mine was from the request not the response) and if you spot a " 308 Permanent Redirect" in the stack trace, the issues could be on the server hosting elastic.

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