Opt for spring-data-elasticsearch 3.2 while staying with spring-boot 2.3

784 views Asked by At

We have a web service running on spring-boot 2.3 with spring-data-r2dbc, which is only available since spring-boot 2.3.

Recently we need to integrate with an existing elasticsearch 6.x cluster, which is not supported by the spring-data-elasticsearch 4.0 that comes with spring-boot 2.3.

I tried to explicitly declare dependency spring-data-elasticsearch 3.2.10 (which supports the 6.x es cluster), however I can see elasticsearch-rest-high-level-client 7.6.2 (this dependency is the root cause of spring-data-elasticsearch 4.0 not supporting 6.x es cluster any more) still loaded regardless of version 6.8.12 declared in spring-data-elasticsearch 3.2.10's pom.xml.

I am using gradle with io.spring.dependency-management and org.springframework.boot plugins. I am wondering how I can stay with spring-boot 2.3, while opting for spring-data-elasticsearch 3.2.10 properly?

========== EDIT ==========

I came across this post Why does Gradle downgrade my transitive dependencies in a Grails 3.1 application? and figured that it is because of io.spring.dependency-management gradle plugin enforcing the elasticsearch version to 7.6.2.

I changed it by ext["elasticsearch.version"] = 6.8.12 and now elasticsearch version is expected.

However, I am still not sure if overriding versions in this way will cause any unforeseen issue.

1

There are 1 answers

1
P.J.Meisch On BEST ANSWER

I don't have a gradle setup to test this, but with maven you need two things:

set the property for the Elasticsearch version and the dependency for Spring Data Elasticsearch:

    <properties>
        <elasticsearch.version>6.8.4</elasticsearch.version>
    </properties>

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>3.2.10.RELEASE</version>
    </dependency>

A first test with a sample program seems to be running ok, but there may be problems, because both spring-data-elasticsearch and spring-data-r2dbc depend on spring-data-commons now in different versions; you'll have to try.