Reputation: 2370
Before elasticsearch 7.16, the ElasticsearchOperations
could be formulated with RestHighLevelClient
@Bean
public ElasticsearchOperations elasticsearchTemplate() {
try {
RestClientBuilder restClientBuilder = RestClient.builder(httpHosts)
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
.setDefaultCredentialsProvider(getElasticCredentialsProvider())
.setKeepAliveStrategy((response, context) -> 3 * 60 * 1000));
return new ElasticsearchRestTemplate(restHighLevelClient);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
Now that RestHighLevelClient is deprecated, I couldn't find a new class to get elasticsearch operations from the new Java client provided.
The dependencies in play are
spring_elasticsearch = 'org.springframework.data:spring-data-elasticsearch:4.4.0-M2'
Upvotes: 0
Views: 1013
Reputation: 19421
I am currently working on integrating the new Elasticsearch client in Spring Data Elasticsearch. We will in the next minor release (4.4) still the RestHighLevelClient
but provide as an optional alternative the possibility to use the new client.
The new client does not yet have the same functionality as the RHLC and still has some error (you might want to have a look at it's issue list), so we cannot already replace it, but the most important reason not to use it in the current version is that the new Client pulls in jakarta
packages instead of javax
and switching by default to the new client would break many existing applications.
A full replacement cannot be done before Spring Data Elasticsearch 5.0, which will use Spring 6, be integrated in Spring Boot 3 as Jakarta EE9 will be only with these releases.
In my opinion, Elasticsearch should not have deprecated the RHLC in a switch of a minor version (ES 7.15 -> 7.16) while providing an incomplete alternative that introduces breaking changes.
So for the time being we have to live with the fact that Spring Data Elasticsearch needs to use a deprecated class.
Upvotes: 1