I hava tried many version of elasticsearch-java but none of it can work.
So, my elasticsearch version is 7.5.2, and the error resonse is like this:
org.elasticsearch.client.ResponseException: method [POST], host [***:80], URI [/location/_search?typed_keys=true], status line [HTTP/1.1 406 Not Acceptable]
{"error":"Content-Type header [application/vnd.elasticsearch+json; compatible-with=7] is not supported","status":406}
When I trying to set the default header like this:
setDefaultHeaders(new Header[]{
new BasicHeader("Content-type", "application/json")
})
And the error response changed to this:
co.elastic.clients.transport.TransportException: [es/search] Missing [X-Elastic-Product] header. Please check that you are connecting to an Elasticsearch instance, and that any networking filters are preserving that header.