We have a scenario where our application needs to connect with both 7.x and 8.x Elasticsearch server. Using Java API client 7.17.16 and it works with Elasticsearch server 7.x. Used (HttpHeaders.CONTENT_TYPE, "application/json") as default header.
However, when using the same headers with Java API client 7.17.16 against Elasticsearch Server 8.x. , it throws an error complaining about headers.
Please let me know what headers I can use against both the servers.
Welcome! Can I confirm which Java client you are using? The Java API client, Java low level client or the deprecated Java REST client? If you could also share the full error message that would be helpful.
I am using Java Api client : 7.17.16. While trying to connect to ElasticServer version 8.10.3
Error message : reason":"A compatible version is required on both Content-Type and Accept headers if either one has requested a compatible version and the compatible versions must match. Accept=application/vnd.elasticsearch+json; compatible-with=7, Content-Type=application/json
What should be the header that will work with both Elasticsearch 7x and Elasticsearch 8x servers.