I am currently working on making our hlrc, which we have configured with spring-data-elasticsearch: 4.4.18, compatible with our new ES8 cluster. I have found a migration guide for this here, but it is not so easy to set with my current client configuration since we use currently not the RestHighLevelClientBuilder but the ClientConfiguration.TerminalClientConfigurationBuilder which doesn't provide this method. Unfortunately, I also have little experience with these clients, which is why I am hoping to get a little help here on how I can set the compatibility mode to true with the current configuration so that communication is possible. Are there any other known problems that can occur with the communication of the higher cluster?
Would be grateful for a little help. :)
@Override
@Bean
public RestHighLevelClient elasticsearchClient() {
ClientConfiguration.TerminalClientConfigurationBuilder clientConfigurationBuilder =
ClientConfiguration.builder()
.connectedTo(env.getProperty("elastic.serverUrl") + ":" + env.getProperty("elastic.serverPort"))
.withBasicAuth(env.getProperty("elastic.user"), env.getProperty("elastic.password"))
.withConnectTimeout(11 * 000).withSocketTimeout(20 * 000);
Boolean disableSsl = Boolean.valueOf(env.getProperty("elastic.disableSsl"));
if (!disableSsl) {
((ClientConfiguration.MaybeSecureClientConfigurationBuilder) clientConfigurationBuilder).usingSsl();
}
return RestClients.create(clientConfigurationBuilder.build()).rest();
}
}
I had a look at that old Elasticsearch code and there seems to be another possibility to set the api compatibility mode besides that call from the
RestHighLevelClientBuilder:So you could try to set the environment variable
ELASTIC_CLIENT_APIVERSIONINGtotruefor your application.But - when you are using an Elasticsearch version 8 - it might make more sense to upgrade your application to a Spring Data Elasticsearch version that is compatible with that.
4.4.x has reached end of support in May 2023, Elastisearch 8 is the default since Spring Data Elasticsearch 5 in November 2022.