I create a client in java and want to get the query results from index but got the 406 error:
"Content-Type header [text/plain] is not supported","status":406.
Java platform: 1.6
ES version: 6.0
Below is the code snippet:
Client clientInstance = Client.create(); clientInstance.addFilter(new HTTPBasicAuthFilter("", "")); // No Auth in sample RI WebResource webResource = clientInstance.resource("http://hostname:9200/indexname/_search"); ClientResponse response = webResource.entity(aggDsl).accept("application/json").get(ClientResponse.class); String resultEntity = response.getEntity(String.class);
I use the DSL in kibana and can get the correct query results. But it did not get the correct response in java and throw 406 error.
How can I fix this issue? Thanks veru much!