Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I disable api-version-compatibility headers? #76

Closed
kid1412621 opened this issue Dec 23, 2021 · 5 comments
Closed

How can I disable api-version-compatibility headers? #76

kid1412621 opened this issue Dec 23, 2021 · 5 comments

Comments

@kid1412621
Copy link

Since some 7.x service do not support these headers, how can I disable this in Java client?

@swallez
Copy link
Member

swallez commented Dec 23, 2021

Starting with version 7.16, the Java client sends these headers to be compatible with Elasticsearch 8.0 that will have a "7.0 compatible mode" to ease the transition to this new major version.

The server-side part of this migration logic was added to Elasticsearch 7.14, and therefore the Java client requires Elasticsearch 7.14 or more. See also our compatibility guarantees.

@swallez swallez closed this as completed Dec 23, 2021
@kid1412621
Copy link
Author

kid1412621 commented Dec 24, 2021

Starting with version 7.16, the Java client sends these headers to be compatible with Elasticsearch 8.0 that will have a "7.0 compatible mode" to ease the transition to this new major version.

The server-side part of this migration logic was added to Elasticsearch 7.14, and therefore the Java client requires Elasticsearch 7.14 or more. See also our compatibility guarantees.

Hi there, I'd like to know if the latest version of java API client supports RestHighLevelClientBuilder#setApiCompatibilityMode. ref: elastic/elasticsearch#51816 (comment)

@kid1412621
Copy link
Author

kid1412621 commented Dec 27, 2021

Hi @swallez, I found a really wired case:

 RestClient restClient = RestClient.builder(
                        new HttpHost("localhost", 9200)).build();

        RestHighLevelClient hlrc = new RestHighLevelClientBuilder(restClient)
                .setApiCompatibilityMode(false)    // disable the compatibility headers
                .build();

        RestClientOptions restClientOptions = new RestClientOptions(RequestOptions.DEFAULT);

        ElasticsearchTransport transport = new RestClientTransport(
                hlrc.getLowLevelClient(), new JacksonJsonpMapper(), restClientOptions);  // override the default headers

        ElasticsearchClient client = new ElasticsearchClient(transport)
                .withTransportOptions(restClientOptions);  // override the default headers again, it seems this don't override above config

Even configured as above, won't disable thoese headers. And it seems something happened here.

@swallez
Copy link
Member

swallez commented Jan 4, 2022

The compatibility mode on the High Level Rest Client only applies to that class, and not to the lower level Rest Client (that one only deals with raw requests and responses). This "opt in" behavior was introduced because it was changing the default behavior of High Level Rest Client.

For Java API client we made a different choice: since the compatibility mode is supported in Elasticsearch since version 7.14 and the Java API client was released as GA in 7.16, we decided to always send the version compatibility information to ease the future transition to Elasticsearch version 8.0 without requiring any change to application code.

@kid1412621
Copy link
Author

The compatibility mode on the High Level Rest Client only applies to that class, and not to the lower level Rest Client (that one only deals with raw requests and responses). This "opt in" behavior was introduced because it was changing the default behavior of High Level Rest Client.

For Java API client we made a different choice: since the compatibility mode is supported in Elasticsearch since version 7.14 and the Java API client was released as GA in 7.16, we decided to always send the version compatibility information to ease the future transition to Elasticsearch version 8.0 without requiring any change to application code.

Good to know, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants