spring-bootelasticsearchspring-data-elasticsearch

ElasticSearch QueryBuilder libaray for Java Spring Boot 3.0.5 is not support


I am new at stackoverflow and happy to learn from all

I am required to upgrade my Java spring boot program from:

After change the pom.xml:

my elasticsearch dependency (org.springframework.boot:spring-boot-starter-data-elasticsearch) also upgrade to 3.0.5. However, I found the following packages are missing:

So I have some questions about the new Elasticsearch client library:

  1. Whether not support using the QueryBuilder again, so I require to change all of service code about using above package?
  2. Whether not support reactive mode at 5.0.5 version? If both answer are YES, it is really painful for me to upgrade it.

The following is the base information of my ES: version: 7.10.1

Also, I have a stupid question want to comfirm: According to the following information provided by Spring-Data-Elasticsearch: https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#preface.versions

If my ES version is 7.10.1, I only can upgrade my spring boot to 2.7.x? or I upgrade to 3.0.5 also can support the older version.

If there are any things missing, I will provide again. Sorry for my poor English and terms. Thank you for anwsering.

I had tried change the pom with following pattern:

Case 1: Upgrade Java from 11 to 17 Upgrade Java Spring Boot from 2.4.2 to 3.0.5 or 3.0.6 Let the org.springframework.boot:spring-boot-starter-data-elasticsearch version same as parent Result: Some ES packages are missing and program cannot be run

Case 2: Upgrade Java from 11 to 17 Keep Java Spring Boot 2.4.2 Upgrade org.springframework.boot:spring-boot-starter-data-elasticsearch to 3.0.5 or 3.0.6 Result: Program run without error

Case 3: Upgrade Java from 11 to 17 Upgrade Java Spring Boot from 2.4.2 to 3.0.5 or 3.0.6 Keep org.springframework.boot:spring-boot-starter-data-elasticsearch:2.4.2 Result: Some ES packages are missing and program cannot be run

Thus, It seems the missing package problems is caused by Upgrade Java Spring Boot from 2.4.2 to 3.0.x


Solution

  • First, you should be able to upgrade the Java version from 11 to 17 without changing your program versions.

    The classes that you are missing come from the integration of the old deprecated RestHighLevelClient library from Elasticsearch. When you need these, it seems you were writing native queries using the classes from this library with a NativeSearchQuery.

    Since Spring Data Elasticsearch 5.0, the new Elasticsearch client library is used. In order to build native queries for this client, you of course need to use the classes from the new client (for an example check the Elasticsearch documentation) and in Spring Data Elasticsearch you will need to use the NativeQuery then. If you build queries using the methods Spring Data Elasticsearch provides (Criteria queries, repository methods or @Query annotated methods), nothing changes.

    With Spring Data Elasticsearch versions 5.0 and 5.1 (released last friday - 12.05.2023 -, will be referenced by the upcoming Spring Boot 3.1) you still can work with the old client library. But this is not the default anymore, it must be configured, check (https://docs.spring.io/spring-data/elasticsearch/docs/5.0.6/reference/html/#elasticsearch.clients.resthighlevelclient) and (https://docs.spring.io/spring-data/elasticsearch/docs/5.0.6/reference/html/#elasticsearch-migration-guide-4.4-5.0.old-client)

    Reactive programming is of course supported in the current versions as well.

    As for the version references in the documentation: These are the versions that are used when developing and testing Spring Data Elasticsearch and so are the minimum requirements. You can try and change the versions that your build is using or the runtime versions when running your applications, but no guarantees that this will work.