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.
CodePudding user response:
The Elastic Java API Client is forward-compatible and not backward. So you can not use it with Elastic 7.5 version. You can use it only with the 7.16 or greater version.
Elasticsearch Java high level client you can use with 7.5 version but it is deprecated now.