Upgrade to Elasticsearch 8.13.2.

Original Pull Request #2893
Closes #2891
This commit is contained in:
Peter-Josef Meisch 2024-04-11 20:11:55 +02:00 committed by GitHub
parent 1d709f6c55
commit bec3beb1eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 35 additions and 9 deletions

View File

@ -21,7 +21,7 @@
<springdata.commons>3.3.0-SNAPSHOT</springdata.commons> <springdata.commons>3.3.0-SNAPSHOT</springdata.commons>
<!-- version of the ElasticsearchClient --> <!-- version of the ElasticsearchClient -->
<elasticsearch-java>8.12.2</elasticsearch-java> <elasticsearch-java>8.13.2</elasticsearch-java>
<blockhound-junit>1.0.8.RELEASE</blockhound-junit> <blockhound-junit>1.0.8.RELEASE</blockhound-junit>
<hoverfly>0.14.4</hoverfly> <hoverfly>0.14.4</hoverfly>

View File

@ -4,7 +4,7 @@
[[new-features.5-3-0]] [[new-features.5-3-0]]
== New in Spring Data Elasticsearch 5.3 == New in Spring Data Elasticsearch 5.3
* Upgrade to Elasticsearch 8.12.2. * Upgrade to Elasticsearch 8.13.2.
* Add support for highlight queries in highlighting. * Add support for highlight queries in highlighting.
* Add shard statistics to the `SearchHit` class. * Add shard statistics to the `SearchHit` class.
* Add support for multi search template API. * Add support for multi search template API.

View File

@ -6,7 +6,7 @@ The following table shows the Elasticsearch and Spring versions that are used by
[cols="^,^,^,^",options="header"] [cols="^,^,^,^",options="header"]
|=== |===
| Spring Data Release Train | Spring Data Elasticsearch | Elasticsearch | Spring Framework | Spring Data Release Train | Spring Data Elasticsearch | Elasticsearch | Spring Framework
| 2024.0 (?) | 5.3.x | 8.12.2 | ? | 2024.0 (?) | 5.3.x | 8.13.2 | ?
| 2023.1 (Vaughan) | 5.2.x | 8.11.1 | 6.1.x | 2023.1 (Vaughan) | 5.2.x | 8.11.1 | 6.1.x
| 2023.0 (Ullmann) | 5.1.x | 8.7.1 | 6.0.x | 2023.0 (Ullmann) | 5.1.x | 8.7.1 | 6.0.x
| 2022.0 (Turing) | 5.0.xfootnote:oom[Out of maintenance] | 8.5.3 | 6.0.x | 2022.0 (Turing) | 5.0.xfootnote:oom[Out of maintenance] | 8.5.3 | 6.0.x

View File

@ -39,6 +39,7 @@ import org.springframework.data.elasticsearch.core.geo.GeoBox;
import org.springframework.data.elasticsearch.core.geo.GeoJson; import org.springframework.data.elasticsearch.core.geo.GeoJson;
import org.springframework.data.elasticsearch.core.geo.GeoPoint; import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import org.springframework.data.elasticsearch.core.query.Criteria; import org.springframework.data.elasticsearch.core.query.Criteria;
import org.springframework.data.elasticsearch.utils.geohash.Geohash;
import org.springframework.data.geo.Box; import org.springframework.data.geo.Box;
import org.springframework.data.geo.Distance; import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Metrics; import org.springframework.data.geo.Metrics;
@ -73,6 +74,9 @@ class CriteriaFilterProcessor {
queriesForEntries(chainedCriteria).forEach(boolQueryBuilder::should); queriesForEntries(chainedCriteria).forEach(boolQueryBuilder::should);
filterQueries.add(new Query(boolQueryBuilder.build())); filterQueries.add(new Query(boolQueryBuilder.build()));
} else if (chainedCriteria.isNegating()) { } else if (chainedCriteria.isNegating()) {
Assert.notNull(criteria.getField(), "criteria must have a field");
Collection<? extends Query> negatingFilters = buildNegatingFilter(criteria.getField().getName(), Collection<? extends Query> negatingFilters = buildNegatingFilter(criteria.getField().getName(),
criteria.getFilterCriteriaEntries()); criteria.getFilterCriteriaEntries());
filterQueries.addAll(negatingFilters); filterQueries.addAll(negatingFilters);
@ -116,6 +120,7 @@ class CriteriaFilterProcessor {
private static Collection<? extends Query> queriesForEntries(Criteria criteria) { private static Collection<? extends Query> queriesForEntries(Criteria criteria) {
Assert.notNull(criteria.getField(), "criteria must have a field"); Assert.notNull(criteria.getField(), "criteria must have a field");
String fieldName = criteria.getField().getName(); String fieldName = criteria.getField().getName();
Assert.notNull(fieldName, "Unknown field"); Assert.notNull(fieldName, "Unknown field");
@ -267,7 +272,10 @@ class CriteriaFilterProcessor {
.tlbr(tlbr -> tlbr // .tlbr(tlbr -> tlbr //
.topLeft(glb -> { .topLeft(glb -> {
if (isGeoHash) { if (isGeoHash) {
glb.geohash(gh -> gh.geohash(topLeft)); // although the builder in 8.13.2 supports geohash, the server throws an error, so we convert to a
// lat,lon string here
glb.text(Geohash.toLatLon(topLeft));
// glb.geohash(gh -> gh.geohash(topLeft));
} else { } else {
glb.text(topLeft); glb.text(topLeft);
} }
@ -275,7 +283,8 @@ class CriteriaFilterProcessor {
}) // }) //
.bottomRight(glb -> { .bottomRight(glb -> {
if (isGeoHash) { if (isGeoHash) {
glb.geohash(gh -> gh.geohash(bottomRight)); glb.text(Geohash.toLatLon(bottomRight));
// glb.geohash(gh -> gh.geohash(bottomRight));
} else { } else {
glb.text(bottomRight); glb.text(bottomRight);
} }

View File

@ -18,6 +18,8 @@ package org.springframework.data.elasticsearch.utils.geohash;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import org.springframework.util.Assert;
/** /**
* Code copied from Elasticsearch 7.10, Apache License V2 * Code copied from Elasticsearch 7.10, Apache License V2
* https://github.com/elastic/elasticsearch/blob/7.10/libs/geo/src/main/java/org/elasticsearch/geometry/utils/Geohash.java * https://github.com/elastic/elasticsearch/blob/7.10/libs/geo/src/main/java/org/elasticsearch/geometry/utils/Geohash.java
@ -70,6 +72,21 @@ public class Geohash {
return new Point(decodeLongitude(hash), decodeLatitude(hash)); return new Point(decodeLongitude(hash), decodeLatitude(hash));
} }
/**
* Converts a geohash to a string in the format "lat,lon"
*
* @param geohash the geohash to convert
* @return the lat lon pair in a String
* @since 5.3
*/
public static String toLatLon(final String geohash) {
Assert.notNull(geohash, "geohash must not be null");
var point = Geohash.toPoint(geohash);
return String.format("%f,%f", point.getLat(), point.getLon());
}
/** /**
* Computes the bounding box coordinates from a given geohash * Computes the bounding box coordinates from a given geohash
* *

View File

@ -15,7 +15,7 @@
# #
# #
sde.testcontainers.image-name=docker.elastic.co/elasticsearch/elasticsearch sde.testcontainers.image-name=docker.elastic.co/elasticsearch/elasticsearch
sde.testcontainers.image-version=8.12.2 sde.testcontainers.image-version=8.13.2
# #
# #
# needed as we do a DELETE /* at the end of the tests, will be required from 8.0 on, produces a warning since 7.13 # needed as we do a DELETE /* at the end of the tests, will be required from 8.0 on, produces a warning since 7.13