1

I want to customize springboot 2.6.8 elasticsearch dependency to elasticsearch 7.17.2, is this ok?

Based on springboot dependency versions, 2.6.8 is mapped to elasticsearch version 7.15.2.

But I want to changed it since elasticsearch version 7.15.2 has some deprecated functions.

How to do it?

the pom.xml I am using does not have spring-boot-starter-data-elasticsearch

and if I use it Maven cannot find it in:

  <repositories>
    <repository>
      <id>shibboleth_repository</id>
      <name>Shibboleth Maven Repository</name>
      <url>https://build.shibboleth.net/nexus/content/repositories/releases/</url>
    </repository>
  </repositories>
<properties>
   <java.version>17</java.version>
 </properties>
 <parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>2.6.8</version>
 </parent>
 <dependencies>
       :
       :
   <dependency>
     <groupId>org.elasticsearch</groupId>
     <artifactId>elasticsearch</artifactId>
   </dependency>
   <dependency>
     <groupId>org.elasticsearch.client</groupId>
     <artifactId>elasticsearch-rest-high-level-client</artifactId>
   </dependency>
       :
 </dependencies>
jetpack
  • 169
  • 1
  • 9
  • As far as I remember, elasticsearch moved some classes to different packages in 7.16, so Spring Data Elasticsearch that was built to use 7.15 will not work with 7.16 or 7.17. – P.J.Meisch Jun 14 '22 at 18:56

1 Answers1

1

I want to customize springboot 2.6.8 elasticsearch dependency to elasticsearch 7.17.2, is this ok?

One never knows until they try. The ElasticSearch version 7.17.2 contains backward-compatible changes 7.15.2, hence it should be ok.

How to do it?

Check the dependency trees:

  • spring-boot-starter-parent:2.6.8
    • spring-boot-starter-data-elasticsearch:2.6.8
      • spring-data-elasticsearch:4.3.4
        • org.elasticsearch.client:...:7.15.2

... and ...

  • spring-boot-starter-parent:2.7.0
    • spring-boot-starter-data-elasticsearch:2.7.7
      • spring-data-elasticsearch:4.4.0
        • org.elasticsearch.client:...:7.17.3

You might want either to update Spring Boot to 2.7.0 for full compatibility that imports transitive dependencies of ElasticSearch version 7.17.3 or override the versions: Exclude all the org.elasticsearch.client dependencies and import them as separate dependencies.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    <exclusions>
        <!-- repeat for all ElasticSearch dependencies -->
        <exclusion>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>...</artifactId>
        </exclusion>
    </exclusions>   
</dependency>

<!-- repeat for all ElasticSearch dependencies -->
<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>...</artifactId>
    <version>7.17.2</version>
</dependency>
Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
  • the pom.xml I am using does not have `spring-boot-starter-data-elasticsearch` – jetpack Jun 10 '22 at 04:59
  • Please, edit your question and don't post it as a comment. You should use `spring-boot-starter-data-elasticsearch` as an Elastic Search starter. In any case, you should be able to override its versions. – Nikolas Charalambidis Jun 10 '22 at 05:07
  • I edit my question....hmmm `spring-boot-starter-data-elasticsearch` seems to not on the pom – jetpack Jun 10 '22 at 05:12
  • I just found out that you can specify the version in – jetpack Jun 10 '22 at 09:49
  • You should check the compatiblity matrix (https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/). ES 7.17.2 support starts from Spring Boot 2.7.x. – downvoteit Dec 11 '22 at 15:18