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
@Bean
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"));
searchSourceBuilder.from(0);
searchSourceBuilder.size(5);
SearchRequest searchRequest = new SearchRequest(new String[] {"myresidents"}, searchSourceBuilder);
SearchResponse searchResponse = null;
try{
searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
}catch (ElasticsearchException ex){
DebugFailedQuery(ex);
}
if(searchResponse!=null){
SearchHits hits = searchResponse.getHits();
}
return null; // still need to deserialize the response.
}