Hi, Java-Spring Boot-Elasticsearch fans
Despite that Elasticsearch was upgraded from 7th to 8th version almost 2 years ago, Spring Boot and Elasticsearch package was adjusted to it relatively recently. When I had to upgrade my project to Elasticsearch 8 version with using spring boot 3 and last spring data Elasticsearch version - I've met a lot of difficulties. Mostly because of 2 main reasons:
too many changes appeared at how Elasticsearch queries are built since Spring Data Elasticsearch 5.x version
lack of good examples at internet, which impressed me a lot
As result I decide to share here some examples, which can be helpful for somebody at his upgrade path
1.Example with range query
Here how it was at previous version Spring Data Elasticsearch versions (3d and 4th):
Here how it looks since Spring Data Elasticsearch 5.x :
2.Example with bool query to create OR condition with match queries
Here how it was at previous version Spring Data Elasticsearch versions (3d and 4th):
Here how it looks since Spring Data Elasticsearch 5.x :
The main thing that was changed is the approach of getting builders. Previously we had universal QueryBuilders class from which we got builders for different types of Elasticsearch queries. From 5x version builders are moved inside Elasticsearch “query” classes. If you are interested at more examples, please visit according article at my blog: "How to work with Elasticsearch 8 using Spring Boot 3"
Top comments (0)