1
0
mirror of synced 2026-05-24 05:03:17 +00:00

Compare commits

..

59 Commits

Author SHA1 Message Date
Mark Paluch a065ba6a76 Release version 5.0.10 (2022.0.10).
See #2673
2023-09-15 10:17:46 +02:00
Mark Paluch 631e5fe496 Prepare 5.0.10 (2022.0.10).
See #2673
2023-09-15 10:17:32 +02:00
Peter-Josef Meisch b1e6e51e16 Fix refresh policy in UpdateQuery.
Original Pull Request #2696
Closes #2692

(cherry picked from commit 2d0aee08ce)
(cherry picked from commit 572cc7ffea)
2023-09-13 21:55:31 +02:00
Peter-Josef Meisch d5df3bfd20 Upgrade deprecated client to Elasticsearch 7.17.13.
Original Pull Request #2695
Closes #2689
2023-09-13 20:05:41 +02:00
Peter-Josef Meisch 7f390845d3 Polishing.
(cherry picked from commit a82952b124)
(cherry picked from commit 4628908e84)
2023-09-03 16:04:19 +02:00
Sébastien Comeau 868a994e33 Fix: missing PhraseSuggestion.Entry.Option's score and collateMatch values.
Original Pull Request #2680
Closes #2681

(cherry picked from commit 7c466395c4)
(cherry picked from commit 922f4b1760)
2023-09-03 16:04:18 +02:00
Peter-Josef Meisch 7d9e6a5a2a Fix search_after field values (#2679)
Closes #2678

(cherry picked from commit 9adc4d2b36)
(cherry picked from commit 4614c62bb5)
2023-08-28 21:19:48 +02:00
Mark Paluch b34ed6fd2b After release cleanups.
See #2629
2023-08-18 10:46:31 +02:00
Mark Paluch ff4e07d350 Prepare next development iteration.
See #2629
2023-08-18 10:46:29 +02:00
Mark Paluch ede29781da Release version 5.0.9 (2022.0.9).
See #2629
2023-08-18 10:43:13 +02:00
Mark Paluch 53a7af879a Prepare 5.0.9 (2022.0.9).
See #2629
2023-08-18 10:42:57 +02:00
Julia Lee c7512fb325 Update CI properties.
See #2629
2023-08-14 10:19:15 -04:00
Julia Lee b4fde9d48b Upgrade to Maven Wrapper 3.9.4.
See #2668
2023-08-14 07:45:53 -04:00
Peter-Josef Meisch 8e56ef77b8 Polishing 2023-08-14 08:15:58 +02:00
Peter-Josef Meisch a2a4114d9c Fix cherrypicked code merge. 2023-08-14 00:01:24 +02:00
Peter-Josef Meisch ec8401a2fb Fix similarity field mapping.
Original Pull Request #2666
Closes #2659

(cherry picked from commit 8c5ff92cd2)
(cherry picked from commit 9b9136d852)

# Conflicts:
#	src/main/java/org/springframework/data/elasticsearch/core/index/MappingParameters.java
#	src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java
2023-08-13 21:43:38 +02:00
Peter-Josef Meisch 19ec05dae3 Upgrade deprecated dependency to Elasticsearch 7.17.12.
Original Pull Request #2654
Closes #2652
2023-07-30 19:24:34 +02:00
Peter-Josef Meisch 70d2de7eec Fix MappingElasticsearchConverter.
Original Pull Request #2637
Closes #2627

(cherry picked from commit d9bb9911f9)
(cherry picked from commit c045a8ae29)
2023-07-18 22:54:56 +02:00
Mark Paluch 1666fcee02 After release cleanups.
See #2594
2023-07-14 11:25:33 +02:00
Mark Paluch c513a0c03e Prepare next development iteration.
See #2594
2023-07-14 11:25:31 +02:00
Mark Paluch 22fe50c73a Release version 5.0.8 (2022.0.8).
See #2594
2023-07-14 11:22:39 +02:00
Mark Paluch ef90755c27 Prepare 5.0.8 (2022.0.8).
See #2594
2023-07-14 11:22:25 +02:00
Peter-Josef Meisch 9153d4dff4 Upgrade to Elasticsearch 7.17.11.
Original Pull Request #2624
Closes #2623
2023-07-12 19:12:01 +02:00
Mark Paluch 9109dfa257 Update CI properties.
See #2594
2023-07-03 09:47:08 +02:00
Mark Paluch 64eee02b85 Upgrade to Maven Wrapper 3.9.3.
See #2613
2023-07-03 09:46:39 +02:00
Peter-Josef Meisch 31365fb722 Fix IndicesBoost error.
Original Pull Request #2606
Closes #2598

(cherry picked from commit d9fd722bb6)
2023-06-27 22:28:38 +02:00
Greg L. Turnquist c218c1d5e3 Stop posting build status on internal Slack.
See #2603
2023-06-26 13:38:31 -05:00
seunghyun.cheong 5bce5dd880 Adding GeoDistanceOrder's direction in request.
Original Pull Request #2602
Closes #2601

(cherry picked from commit 8a164b1039)

Polishing

(cherry picked from commit b7570ffa95)

add implementation for old client

(cherry picked from commit d43b44ba9c)

# Conflicts:
#	src/main/java/org/springframework/data/elasticsearch/client/elc/RequestConverter.java
#	src/main/java/org/springframework/data/elasticsearch/client/erhlc/RequestFactory.java
2023-06-24 11:58:57 +02:00
Mark Paluch 32c4c4d03f After release cleanups.
See #2547
2023-06-16 15:43:11 +02:00
Mark Paluch 5102d98e10 Prepare next development iteration.
See #2547
2023-06-16 15:43:09 +02:00
Mark Paluch 57a4b755c1 Release version 5.0.7 (2022.0.7).
See #2547
2023-06-16 15:39:46 +02:00
Mark Paluch edaae2a4e8 Prepare 5.0.7 (2022.0.7).
See #2547
2023-06-16 15:39:31 +02:00
Mark Paluch 4747caf57a Upgrade to Maven Wrapper 3.9.2.
See #2587
2023-06-13 08:52:21 +02:00
Mark Paluch aba2ff6f5c Polishing.
Remove Lombok version override.

See #2585
2023-06-07 08:57:07 +02:00
Mark Paluch 0dc2902cab Reformat pom.xml.
See #2585
2023-06-06 10:58:01 +02:00
Mark Paluch 3c60e5f9cc Use snapshot and milestone repositories instead of libs-snapshot and libs-milestone.
Closes #2585
2023-06-06 10:57:44 +02:00
Peter-Josef Meisch ef822355ac Polishing
(cherry picked from commit 6edd3cf1fe)
2023-05-17 20:35:31 +02:00
Pierre Mazieres @Semarchy 94d23a1403 "BaseQuery" class : the "build" method does not apply to the "runtimeFields" field.
Original Pull Request #2568
Closes #2567

(cherry picked from commit 7b527c4451)

# Conflicts:
#	src/main/java/org/springframework/data/elasticsearch/core/query/BaseQuery.java
2023-05-17 20:35:25 +02:00
Christoph Strobl 13b4d62031 After release cleanups.
See #2528
2023-05-12 11:11:32 +02:00
Christoph Strobl 1087b0355f Prepare next development iteration.
See #2528
2023-05-12 11:11:31 +02:00
Christoph Strobl 22ed898d63 Release version 5.0.6 (2022.0.6).
See #2528
2023-05-12 11:08:07 +02:00
Christoph Strobl a474a0f533 Prepare 5.0.6 (2022.0.6).
See #2528
2023-05-12 11:07:48 +02:00
Pierre Mazieres @Semarchy 1d23fb14fa Fix assignment in NativeQueryBuilder.
Original Pull Request: #2543
Closes #2542

(cherry picked from commit 9c497c2dea)
2023-05-10 18:34:06 +02:00
Greg L. Turnquist e1741ca255 After release cleanups.
See #2499
2023-04-14 10:25:06 -05:00
Greg L. Turnquist 3e4477af16 Prepare next development iteration.
See #2499
2023-04-14 10:25:01 -05:00
Greg L. Turnquist 2244f855f3 Release version 5.0.5 (2022.0.5).
See #2499
2023-04-14 10:19:16 -05:00
Greg L. Turnquist 03265a4551 Prepare 5.0.5 (2022.0.5).
See #2499
2023-04-14 10:18:35 -05:00
Peter-Josef Meisch fdc03cf29e Polishing
(cherry picked from commit dfc1be286c)
2023-04-10 11:30:05 +02:00
JKatzwinkel e1da43ca9f Fix inner hits metadata mapping.
Original Pull Request #2522
Closes #2521

(cherry picked from commit 1f7fa77c15)
2023-04-10 11:30:05 +02:00
Mark Paluch 4a1a4d3851 Upgrade to Maven Wrapper 3.9.1.
See #2519
2023-04-06 16:17:39 +02:00
Greg L. Turnquist a9ee467455 Test against Java 20 on CI.
See #2507.
2023-03-30 11:52:11 -05:00
Greg L. Turnquist ebccb34db1 Upgrade to BlockHound 1.0.7.RELEASE.
Closes #2510.
2023-03-30 11:52:01 -05:00
Greg L. Turnquist d1e349f689 Update CI properties.
See #2499
2023-03-28 14:01:12 -05:00
Christoph Strobl b8722bab84 After release cleanups.
See #2485
2023-03-20 14:26:21 +01:00
Christoph Strobl 9e35f70833 Prepare next development iteration.
See #2485
2023-03-20 14:26:20 +01:00
Christoph Strobl 59f3a6b120 Release version 5.0.4 (2022.0.4).
See #2485
2023-03-20 14:22:49 +01:00
Christoph Strobl e534e952a1 Prepare 5.0.4 (2022.0.4).
See #2485
2023-03-20 14:22:21 +01:00
Mark Paluch 868a9d049a After release cleanups.
See #2462
2023-03-03 11:02:48 +01:00
Mark Paluch 28727c6b36 Prepare next development iteration.
See #2462
2023-03-03 11:02:46 +01:00
23 changed files with 454 additions and 176 deletions
+2 -2
View File
@@ -1,3 +1,3 @@
#Mon Feb 20 11:59:41 CET 2023
#Mon Aug 14 07:45:53 EDT 2023
wrapperUrl=https\://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip
distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
Vendored
+43 -24
View File
@@ -1,7 +1,7 @@
def p = [:]
node {
checkout scm
p = readProperties interpolate: true, file: 'ci/pipeline.properties'
checkout scm
p = readProperties interpolate: true, file: 'ci/pipeline.properties'
}
pipeline {
@@ -18,7 +18,7 @@ pipeline {
}
stages {
stage("test: baseline (Java 17)") {
stage("test: baseline (main)") {
when {
beforeAgent(true)
anyOf {
@@ -32,17 +32,42 @@ pipeline {
options { timeout(time: 30, unit: 'MINUTES') }
environment {
DOCKER_HUB = credentials("${p['docker.credentials']}")
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
}
steps {
script {
docker.withRegistry(p['docker.registry'], p['docker.credentials']) {
docker.image(p['docker.java.main.image']).inside(p['docker.java.inside.docker']) {
sh "docker login --username ${DOCKER_HUB_USR} --password ${DOCKER_HUB_PSW}"
sh 'PROFILE=none ci/verify.sh'
sh "ci/clean.sh"
docker.image(p['docker.java.main.image']).inside(p['docker.java.inside.docker']) {
sh 'PROFILE=none ci/verify.sh'
sh "ci/clean.sh"
}
}
}
}
stage("Test other configurations") {
when {
beforeAgent(true)
allOf {
branch(pattern: "main|(\\d\\.\\d\\.x)", comparator: "REGEXP")
not { triggeredBy 'UpstreamCause' }
}
}
parallel {
stage("test: baseline (next)") {
agent {
label 'data'
}
options { timeout(time: 30, unit: 'MINUTES') }
environment {
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
}
steps {
script {
docker.image(p['docker.java.next.image']).inside(p['docker.java.inside.docker']) {
sh 'PROFILE=none ci/verify.sh'
sh "ci/clean.sh"
}
}
}
}
@@ -68,17 +93,15 @@ pipeline {
steps {
script {
docker.withRegistry(p['docker.registry'], p['docker.credentials']) {
docker.image(p['docker.java.main.image']).inside(p['docker.java.inside.basic']) {
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,artifactory -Dmaven.repo.local=/tmp/jenkins-home/.m2/spring-data-elasticsearch-non-root ' +
'-Dartifactory.server=https://repo.spring.io ' +
"-Dartifactory.username=${ARTIFACTORY_USR} " +
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
"-Dartifactory.staging-repository=libs-snapshot-local " +
"-Dartifactory.build-name=spring-data-elasticsearch " +
"-Dartifactory.build-number=${BUILD_NUMBER} " +
'-Dmaven.test.skip=true clean deploy -U -B'
}
docker.image(p['docker.java.main.image']).inside(p['docker.java.inside.basic']) {
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,artifactory -Dmaven.repo.local=/tmp/jenkins-home/.m2/spring-data-elasticsearch-non-root ' +
'-Dartifactory.server=https://repo.spring.io ' +
"-Dartifactory.username=${ARTIFACTORY_USR} " +
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
"-Dartifactory.staging-repository=libs-snapshot-local " +
"-Dartifactory.build-name=spring-data-elasticsearch " +
"-Dartifactory.build-number=${BUILD_NUMBER} " +
'-Dmaven.test.skip=true clean deploy -U -B'
}
}
}
@@ -88,10 +111,6 @@ pipeline {
post {
changed {
script {
slackSend(
color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger',
channel: '#spring-data-dev',
message: "${currentBuild.fullDisplayName} - `${currentBuild.currentResult}`\n${env.BUILD_URL}")
emailext(
subject: "[${currentBuild.fullDisplayName}] ${currentBuild.currentResult}",
mimeType: 'text/html',
+4 -4
View File
@@ -137,9 +137,9 @@ To use the Release candidate versions of the upcoming major version, use our Mav
</dependency>
<repository>
<id>spring-libs-snapshot</id>
<id>spring-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/libs-milestone</url>
<url>https://repo.spring.io/milestone</url>
</repository>
----
@@ -154,9 +154,9 @@ If you'd rather like the latest snapshots of the upcoming major version, use our
</dependency>
<repository>
<id>spring-libs-snapshot</id>
<id>spring-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>https://repo.spring.io/libs-snapshot</url>
<url>https://repo.spring.io/snapshot</url>
</repository>
----
+8 -6
View File
@@ -1,19 +1,21 @@
# Java versions
java.main.tag=17.0.6_10-jdk-focal
java.main.tag=17.0.8_7-jdk-focal
java.next.tag=20-jdk-jammy
# Docker container images - standard
docker.java.main.image=harbor-repo.vmware.com/dockerhub-proxy-cache/library/eclipse-temurin:${java.main.tag}
docker.java.next.image=harbor-repo.vmware.com/dockerhub-proxy-cache/library/eclipse-temurin:${java.next.tag}
# Supported versions of MongoDB
docker.mongodb.4.4.version=4.4.18
docker.mongodb.5.0.version=5.0.14
docker.mongodb.6.0.version=6.0.4
docker.mongodb.4.4.version=4.4.23
docker.mongodb.5.0.version=5.0.19
docker.mongodb.6.0.version=6.0.8
# Supported versions of Redis
docker.redis.6.version=6.2.10
docker.redis.6.version=6.2.13
# Supported versions of Cassandra
docker.cassandra.3.version=3.11.14
docker.cassandra.3.version=3.11.15
# Docker environment settings
docker.java.inside.basic=-v $HOME:/tmp/jenkins-home
+8 -41
View File
@@ -5,12 +5,12 @@
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>5.0.3</version>
<version>5.0.10</version>
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>3.0.3</version>
<version>3.0.10</version>
</parent>
<name>Spring Data Elasticsearch</name>
@@ -18,17 +18,17 @@
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
<properties>
<springdata.commons>3.0.3</springdata.commons>
<springdata.commons>3.0.10</springdata.commons>
<!-- version of the RestHighLevelClient -->
<elasticsearch-rhlc>7.17.9</elasticsearch-rhlc>
<elasticsearch-rhlc>7.17.13</elasticsearch-rhlc>
<!-- version of the new ElasticsearchClient -->
<elasticsearch-java>8.5.3</elasticsearch-java>
<log4j>2.18.0</log4j>
<netty>4.1.65.Final</netty>
<blockhound-junit>1.0.6.RELEASE</blockhound-junit>
<blockhound-junit>1.0.7.RELEASE</blockhound-junit>
<hoverfly>0.14.3</hoverfly>
<jsonassert>1.5.1</jsonassert>
<testcontainers>1.17.3</testcontainers>
@@ -279,24 +279,6 @@
<scope>test</scope>
</dependency>
<!--
we don't use lombok in Spring Data Elasticsearch anymore. But the dependency is set in the parent project, and so the
lombok compiler stuff is executed regardless of the fact that we don't need it.
On AdoptOpenJdk 16.0.0 this leads to an error, so the project does not build.
Therefore we replace lombok with a jar - that just contains an empty file - that lives in a local maven repository in
src/test/resources/local-maven-repo/
It was installed with
mvn deploy:deploy-file -DgroupId=org.projectlombok -DartifactId=lombok -Dversion=999999 -Durl=file:./src/test/resources/local-maven-repo/ -DrepositoryId=local-maven-repo -DupdateReleaseInfo=true -Dfile=path/to/empty.jar
-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<!--suppress MavenPackageUpdate -->
<version>999999</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
@@ -466,7 +448,7 @@
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
</plugin>
</plugins>
</plugins>
</build>
<profiles>
@@ -519,23 +501,8 @@
</profiles>
<repositories>
<repository>
<id>spring-libs-release</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>local-maven-repo</id>
<url>file:///${project.basedir}/src/test/resources/local-maven-repo</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-plugins-release</id>
<url>https://repo.spring.io/plugins-release</url>
</pluginRepository>
</pluginRepositories>
</project>
+3 -3
View File
@@ -17,9 +17,9 @@ include::reference/elasticsearch-new.adoc[leveloffset=+1]
* Version Control - https://github.com/spring-projects/spring-data-elasticsearch
* API Documentation - https://docs.spring.io/spring-data/elasticsearch/docs/current/api/
* Bugtracker - https://github.com/spring-projects/spring-data-elasticsearch/issues
* Release repository - https://repo.spring.io/libs-release
* Milestone repository - https://repo.spring.io/libs-milestone
* Snapshot repository - https://repo.spring.io/libs-snapshot
* Release repository - https://repo1.maven.org/maven2/
* Milestone repository - https://repo.spring.io/milestone/
* Snapshot repository - https://repo.spring.io/snapshot/
[[preface.requirements]]
== Requirements
@@ -154,7 +154,7 @@ The old deprecated `RestHighLevelClient` can still be used, but you will need to
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.17.9</version>
<version>7.17.12</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
@@ -165,4 +165,4 @@ The old deprecated `RestHighLevelClient` can still be used, but you will need to
----
====
Make sure to specify the version 7.17.9 explicitly, otherwise maven will resolve to 8.5.3, and this does not exist.
Make sure to specify the version 7.17.12 explicitly, otherwise maven will resolve to 8.5.3, and this does not exist.
@@ -184,7 +184,7 @@ public class NativeQueryBuilder extends BaseQueryBuilder<NativeQuery, NativeQuer
Assert.notNull(searchExtensions, "searchExtensions must not be null");
searchExtensions.putAll(searchExtensions);
this.searchExtensions.putAll(searchExtensions);
return this;
}
@@ -15,15 +15,10 @@
*/
package org.springframework.data.elasticsearch.client.elc;
import static org.springframework.data.elasticsearch.client.elc.TypeUtils.searchType;
import static org.springframework.data.elasticsearch.client.elc.TypeUtils.slices;
import static org.springframework.data.elasticsearch.client.elc.TypeUtils.time;
import static org.springframework.data.elasticsearch.client.elc.TypeUtils.timeStringMs;
import static org.springframework.data.elasticsearch.client.elc.TypeUtils.toFloat;
import static org.springframework.util.CollectionUtils.isEmpty;
import static org.springframework.data.elasticsearch.client.elc.TypeUtils.*;
import static org.springframework.util.CollectionUtils.*;
import co.elastic.clients.elasticsearch._types.Conflicts;
import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch._types.InlineScript;
import co.elastic.clients.elasticsearch._types.OpType;
import co.elastic.clients.elasticsearch._types.SortOptions;
@@ -37,18 +32,7 @@ import co.elastic.clients.elasticsearch._types.mapping.RuntimeFieldType;
import co.elastic.clients.elasticsearch._types.mapping.TypeMapping;
import co.elastic.clients.elasticsearch._types.query_dsl.Like;
import co.elastic.clients.elasticsearch.cluster.HealthRequest;
import co.elastic.clients.elasticsearch.core.BulkRequest;
import co.elastic.clients.elasticsearch.core.ClosePointInTimeRequest;
import co.elastic.clients.elasticsearch.core.DeleteByQueryRequest;
import co.elastic.clients.elasticsearch.core.DeleteRequest;
import co.elastic.clients.elasticsearch.core.GetRequest;
import co.elastic.clients.elasticsearch.core.IndexRequest;
import co.elastic.clients.elasticsearch.core.MgetRequest;
import co.elastic.clients.elasticsearch.core.MsearchRequest;
import co.elastic.clients.elasticsearch.core.OpenPointInTimeRequest;
import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.UpdateByQueryRequest;
import co.elastic.clients.elasticsearch.core.UpdateRequest;
import co.elastic.clients.elasticsearch.core.*;
import co.elastic.clients.elasticsearch.core.bulk.BulkOperation;
import co.elastic.clients.elasticsearch.core.bulk.CreateOperation;
import co.elastic.clients.elasticsearch.core.bulk.IndexOperation;
@@ -58,17 +42,8 @@ import co.elastic.clients.elasticsearch.core.msearch.MultisearchBody;
import co.elastic.clients.elasticsearch.core.search.Highlight;
import co.elastic.clients.elasticsearch.core.search.Rescore;
import co.elastic.clients.elasticsearch.core.search.SourceConfig;
import co.elastic.clients.elasticsearch.indices.CreateIndexRequest;
import co.elastic.clients.elasticsearch.indices.DeleteIndexRequest;
import co.elastic.clients.elasticsearch.indices.*;
import co.elastic.clients.elasticsearch.indices.ExistsRequest;
import co.elastic.clients.elasticsearch.indices.GetAliasRequest;
import co.elastic.clients.elasticsearch.indices.GetIndexRequest;
import co.elastic.clients.elasticsearch.indices.GetIndicesSettingsRequest;
import co.elastic.clients.elasticsearch.indices.GetMappingRequest;
import co.elastic.clients.elasticsearch.indices.IndexSettings;
import co.elastic.clients.elasticsearch.indices.PutMappingRequest;
import co.elastic.clients.elasticsearch.indices.RefreshRequest;
import co.elastic.clients.elasticsearch.indices.UpdateAliasesRequest;
import co.elastic.clients.elasticsearch.indices.update_aliases.Action;
import co.elastic.clients.json.JsonData;
import co.elastic.clients.json.JsonpDeserializer;
@@ -85,7 +60,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@@ -107,19 +81,7 @@ import org.springframework.data.elasticsearch.core.index.PutTemplateRequest;
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.BaseQuery;
import org.springframework.data.elasticsearch.core.query.BulkOptions;
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
import org.springframework.data.elasticsearch.core.query.GeoDistanceOrder;
import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
import org.springframework.data.elasticsearch.core.query.Order;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.RescorerQuery;
import org.springframework.data.elasticsearch.core.query.ScriptData;
import org.springframework.data.elasticsearch.core.query.SourceFilter;
import org.springframework.data.elasticsearch.core.query.StringQuery;
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.elasticsearch.core.query.*;
import org.springframework.data.elasticsearch.core.reindex.ReindexRequest;
import org.springframework.data.elasticsearch.core.reindex.Remote;
import org.springframework.data.elasticsearch.support.DefaultStringObjectMap;
@@ -918,7 +880,7 @@ class RequestConverter {
.docAsUpsert(query.getDocAsUpsert()) //
.ifSeqNo(query.getIfSeqNo() != null ? Long.valueOf(query.getIfSeqNo()) : null) //
.ifPrimaryTerm(query.getIfPrimaryTerm() != null ? Long.valueOf(query.getIfPrimaryTerm()) : null) //
.refresh(TypeUtils.refresh(refreshPolicy)) //
.refresh(query.getRefreshPolicy() != null ? refresh(query.getRefreshPolicy()) : refresh(refreshPolicy)) //
.retryOnConflict(query.getRetryOnConflict()) //
;
@@ -1121,8 +1083,7 @@ class RequestConverter {
}
if (!isEmpty(query.getSearchAfter())) {
bb.searchAfter(query.getSearchAfter().stream().map(it -> FieldValue.of(it.toString()))
.collect(Collectors.toList()));
bb.searchAfter(query.getSearchAfter().stream().map(TypeUtils::toFieldValue).toList());
}
query.getRescorerQueries().forEach(rescorerQuery -> bb.rescore(getRescore(rescorerQuery)));
@@ -1146,11 +1107,9 @@ class RequestConverter {
}
if (!isEmpty(query.getIndicesBoost())) {
Map<String, Double> boosts = new LinkedHashMap<>();
query.getIndicesBoost()
.forEach(indexBoost -> boosts.put(indexBoost.getIndexName(), (double) indexBoost.getBoost()));
// noinspection unchecked
bb.indicesBoost(boosts);
bb.indicesBoost(query.getIndicesBoost().stream()
.map(indexBoost -> Map.of(indexBoost.getIndexName(), Double.valueOf(indexBoost.getBoost())))
.collect(Collectors.toList()));
}
if (query instanceof NativeQuery) {
@@ -1263,8 +1222,7 @@ class RequestConverter {
}
if (!isEmpty(query.getSearchAfter())) {
builder.searchAfter(
query.getSearchAfter().stream().map(it -> FieldValue.of(it.toString())).collect(Collectors.toList()));
builder.searchAfter(query.getSearchAfter().stream().map(TypeUtils::toFieldValue).toList());
}
query.getRescorerQueries().forEach(rescorerQuery -> builder.rescore(getRescore(rescorerQuery)));
@@ -1301,11 +1259,9 @@ class RequestConverter {
}
if (!isEmpty(query.getIndicesBoost())) {
Map<String, Double> boosts = new LinkedHashMap<>();
query.getIndicesBoost()
.forEach(indexBoost -> boosts.put(indexBoost.getIndexName(), (double) indexBoost.getBoost()));
// noinspection unchecked
builder.indicesBoost(boosts);
builder.indicesBoost(query.getIndicesBoost().stream()
.map(indexBoost -> Map.of(indexBoost.getIndexName(), Double.valueOf(indexBoost.getBoost())))
.collect(Collectors.toList()));
}
}
@@ -1373,9 +1329,10 @@ class RequestConverter {
return SortOptions.of(so -> so //
.geoDistance(gd -> gd //
.field(fieldName) //
.location(loc -> loc.latlon(QueryBuilders.latLon(geoDistanceOrder.getGeoPoint())))//
.location(loc -> loc.latlon(QueryBuilders.latLon(geoDistanceOrder.getGeoPoint()))) //
.distanceType(TypeUtils.geoDistanceType(geoDistanceOrder.getDistanceType()))
.mode(TypeUtils.sortMode(finalMode)) //
.order(TypeUtils.sortOrder(geoDistanceOrder.getDirection())) //
.unit(TypeUtils.distanceUnit(geoDistanceOrder.getUnit())) //
.ignoreUnmapped(geoDistanceOrder.getIgnoreUnmapped())));
} else {
@@ -192,7 +192,8 @@ class SearchDocumentResponseBuilder {
var phraseSuggestOptions = phraseSuggest.options();
List<PhraseSuggestion.Entry.Option> options = new ArrayList<>();
phraseSuggestOptions.forEach(optionES -> options
.add(new PhraseSuggestion.Entry.Option(optionES.text(), optionES.highlighted(), null, null)));
.add(new PhraseSuggestion.Entry.Option(optionES.text(), optionES.highlighted(), optionES.score(),
optionES.collateMatch())));
entries.add(new PhraseSuggestion.Entry(phraseSuggest.text(), phraseSuggest.offset(), phraseSuggest.length(),
options, null));
});
@@ -24,9 +24,11 @@ import co.elastic.clients.elasticsearch.core.search.HighlighterOrder;
import co.elastic.clients.elasticsearch.core.search.HighlighterTagsSchema;
import co.elastic.clients.elasticsearch.core.search.HighlighterType;
import co.elastic.clients.elasticsearch.core.search.ScoreMode;
import co.elastic.clients.json.JsonData;
import java.time.Duration;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.core.RefreshPolicy;
import org.springframework.data.elasticsearch.core.query.GeoDistanceOrder;
import org.springframework.data.elasticsearch.core.query.IndexQuery;
@@ -126,6 +128,40 @@ final class TypeUtils {
}
}
@Nullable
static FieldValue toFieldValue(@Nullable Object fieldValue) {
if (fieldValue == null) {
return FieldValue.NULL;
}
if (fieldValue instanceof Boolean b) {
return b ? FieldValue.TRUE : FieldValue.FALSE;
}
if (fieldValue instanceof String s) {
return FieldValue.of(s);
}
if (fieldValue instanceof Long l) {
return FieldValue.of(l);
}
if (fieldValue instanceof Integer i) {
return FieldValue.of((long) i);
}
if (fieldValue instanceof Double d) {
return FieldValue.of(d);
}
if (fieldValue instanceof Float f) {
return FieldValue.of((double) f);
}
return FieldValue.of(JsonData.of(fieldValue));
}
@Nullable
static GeoDistanceType geoDistanceType(GeoDistanceOrder.DistanceType distanceType) {
@@ -136,6 +172,20 @@ final class TypeUtils {
}
@Nullable
static SortOrder sortOrder(@Nullable Sort.Direction direction) {
if (direction == null) {
return null;
}
return switch (direction) {
case ASC -> SortOrder.Asc;
case DESC -> SortOrder.Desc;
};
}
@Nullable
static HighlighterFragmenter highlighterFragmenter(@Nullable String value) {
@@ -963,6 +963,8 @@ class RequestFactory {
sort.ignoreUnmapped(geoDistanceOrder.getIgnoreUnmapped());
}
sort.order(order.isAscending() ? SortOrder.ASC : SortOrder.DESC);
return sort;
} else {
FieldSortBuilder sort = SortBuilders //
@@ -45,6 +45,7 @@ import org.springframework.util.Assert;
* @author Roman Puchkovskiy
* @author Matt Gilene
* @author Sascha Woo
* @author Jakob Hoeper
* @since 4.0
*/
public class SearchHitMapping<T> {
@@ -199,9 +200,10 @@ public class SearchHitMapping<T> {
}
try {
ElasticsearchPersistentEntity<?> persistentEntityForType = mappingContext.getPersistentEntity(type);
NestedMetaData nestedMetaData = searchHits.getSearchHit(0).getContent().getNestedMetaData();
ElasticsearchPersistentEntityWithNestedMetaData persistentEntityWithNestedMetaData = getPersistentEntity(
mappingContext.getPersistentEntity(type), nestedMetaData);
persistentEntityForType, nestedMetaData);
if (persistentEntityWithNestedMetaData.entity != null) {
List<SearchHit<Object>> convertedSearchHits = new ArrayList<>();
@@ -219,7 +221,8 @@ public class SearchHitMapping<T> {
searchDocument.getSortValues(), //
searchDocument.getHighlightFields(), //
searchHit.getInnerHits(), //
persistentEntityWithNestedMetaData.nestedMetaData, //
getPersistentEntity(persistentEntityForType, //
searchHit.getContent().getNestedMetaData()).nestedMetaData, //
searchHit.getExplanation(), //
searchHit.getMatchedQueries(), //
targetObject));
@@ -919,7 +919,7 @@ public class MappingElasticsearchConverter
Class<?> elementType = element == null ? null : element.getClass();
if (elementType == null || conversions.isSimpleType(elementType)) {
if (elementType == null || isSimpleType(elementType)) {
collection.add(getPotentiallyConvertedSimpleWrite(element,
componentType != null ? componentType.getType() : Object.class));
} else if (element instanceof Collection || elementType.isArray()) {
@@ -332,6 +332,8 @@ public final class MappingParameters {
if (similarity != Similarity.Default) {
objectNode.put(FIELD_PARAM_SIMILARITY, similarity.toString());
// similarity must have index explicitly set, otherwise Elasticsearch returns an error
objectNode.put(FIELD_PARAM_INDEX, index);
}
if (termVector != TermVector.none) {
@@ -71,7 +71,7 @@ public class BaseQuery implements Query {
protected List<RescorerQuery> rescorerQueries = new ArrayList<>();
@Nullable protected Boolean requestCache;
protected List<IdWithRouting> idsWithRouting = Collections.emptyList();
protected final List<RuntimeField> runtimeFields = new ArrayList<>();
protected List<RuntimeField> runtimeFields = new ArrayList<>();
@Nullable protected PointInTime pointInTime;
private boolean queryIsUpdatedByConverter = false;
@@ -105,6 +105,14 @@ public class BaseQuery implements Query {
this.requestCache = builder.getRequestCache();
this.idsWithRouting = builder.getIdsWithRouting();
this.pointInTime = builder.getPointInTime();
this.runtimeFields = builder.getRuntimeFields();
}
/**
* @since 5.1
*/
public void setSort(@Nullable Sort sort) {
this.sort = sort;
}
@Override
+8 -1
View File
@@ -1,4 +1,4 @@
Spring Data Elasticsearch 5.0.3 (2022.0.3)
Spring Data Elasticsearch 5.0.10 (2022.0.10)
Copyright (c) [2013-2021] Pivotal Software, Inc.
This product is licensed to you under the Apache License, Version 2.0 (the "License").
@@ -19,3 +19,10 @@ conditions of the subcomponent's license, as noted in the LICENSE file.
@@ -0,0 +1,111 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.elasticsearch.client.elc;
import co.elastic.clients.elasticsearch.core.search.HitsMetadata;
import co.elastic.clients.elasticsearch.core.search.Suggestion;
import co.elastic.clients.elasticsearch.core.search.TotalHitsRelation;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import java.util.ArrayList;
import java.util.List;
import org.assertj.core.api.SoftAssertions;
import org.json.JSONException;
import org.junit.jupiter.api.Test;
import org.springframework.data.elasticsearch.core.document.SearchDocumentResponse;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
/**
* Tests for the factory class to create {@link SearchDocumentResponse} instances.
*
* @author Sébastien Comeau
* @since 5.2
*/
class SearchDocumentResponseBuilderUnitTests {
private JacksonJsonpMapper jsonpMapper = new JacksonJsonpMapper();
@Test // #2681
void shouldGetPhraseSuggestion() throws JSONException {
// arrange
final var hitsMetadata = new HitsMetadata.Builder<EntityAsMap>()
.total(total -> total
.value(0)
.relation(TotalHitsRelation.Eq))
.hits(new ArrayList<>())
.build();
final var suggestionTest = new Suggestion.Builder<EntityAsMap>()
.phrase(phrase -> phrase
.text("National")
.offset(0)
.length(8)
.options(option -> option
.text("nations")
.highlighted("highlighted-nations")
.score(0.11480146)
.collateMatch(false))
.options(option -> option
.text("national")
.highlighted("highlighted-national")
.score(0.08063514)
.collateMatch(false)))
.build();
final var sortProperties = ImmutableMap.<String, List<Suggestion<EntityAsMap>>> builder()
.put("suggestionTest", ImmutableList.of(suggestionTest))
.build();
// act
final var actual = SearchDocumentResponseBuilder.from(hitsMetadata, null, null, null, sortProperties, null,
jsonpMapper);
// assert
SoftAssertions softly = new SoftAssertions();
softly.assertThat(actual).isNotNull();
softly.assertThat(actual.getSuggest()).isNotNull();
softly.assertThat(actual.getSuggest().getSuggestions()).isNotNull().hasSize(1);
final var actualSuggestion = actual.getSuggest().getSuggestions().get(0);
softly.assertThat(actualSuggestion.getName()).isEqualTo("suggestionTest");
softly.assertThat(actualSuggestion.getEntries()).isNotNull().hasSize(1);
final var actualEntry = actualSuggestion.getEntries().get(0);
softly.assertThat(actualEntry).isNotNull();
softly.assertThat(actualEntry.getText()).isEqualTo("National");
softly.assertThat(actualEntry.getOffset()).isEqualTo(0);
softly.assertThat(actualEntry.getLength()).isEqualTo(8);
softly.assertThat(actualEntry.getOptions()).isNotNull().hasSize(2);
final var actualOption1 = actualEntry.getOptions().get(0);
softly.assertThat(actualOption1.getText()).isEqualTo("nations");
softly.assertThat(actualOption1.getHighlighted()).isEqualTo("highlighted-nations");
softly.assertThat(actualOption1.getScore()).isEqualTo(0.11480146);
softly.assertThat(actualOption1.getCollateMatch()).isEqualTo(false);
final var actualOption2 = actualEntry.getOptions().get(1);
softly.assertThat(actualOption2.getText()).isEqualTo("national");
softly.assertThat(actualOption2.getHighlighted()).isEqualTo("highlighted-national");
softly.assertThat(actualOption2.getScore()).isEqualTo(0.08063514);
softly.assertThat(actualOption2.getCollateMatch()).isEqualTo(false);
softly.assertAll();
}
}
@@ -42,6 +42,7 @@ import org.springframework.lang.Nullable;
* Testing the querying and parsing of inner_hits.
*
* @author Peter-Josef Meisch
* @author Jakob Hoeper
*/
@SpringIntegrationTest
public abstract class InnerHitsIntegrationTests {
@@ -58,8 +59,9 @@ public abstract class InnerHitsIntegrationTests {
indexOps.createWithMapping();
Inhabitant john = new Inhabitant("John", "Smith");
Inhabitant carla = new Inhabitant("Carla", "Miller");
House cornerHouse = new House("Round the corner", "7", Arrays.asList(john, carla));
Inhabitant carla1 = new Inhabitant("Carla", "Miller");
Inhabitant carla2 = new Inhabitant("Carla", "Nguyen");
House cornerHouse = new House("Round the corner", "7", Arrays.asList(john, carla1, carla2));
City metropole = new City("Metropole", Arrays.asList(cornerHouse));
Inhabitant jack = new Inhabitant("Jack", "Wayne");
@@ -76,7 +78,7 @@ public abstract class InnerHitsIntegrationTests {
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete();
}
@Test
@Test // #2521
void shouldReturnInnerHits() {
Query query = buildQueryForInnerHits("inner_hit_name", "hou-ses.in-habi-tants", "hou-ses.in-habi-tants.first-name",
@@ -91,7 +93,7 @@ public abstract class InnerHitsIntegrationTests {
softly.assertThat(searchHit.getInnerHits()).hasSize(1);
SearchHits<?> innerHits = searchHit.getInnerHits("inner_hit_name");
softly.assertThat(innerHits).hasSize(1);
softly.assertThat(innerHits).hasSize(2);
SearchHit<?> innerHit = innerHits.getSearchHit(0);
Object content = innerHit.getContent();
@@ -106,6 +108,10 @@ public abstract class InnerHitsIntegrationTests {
softly.assertThat(nestedMetaData.getChild().getField()).isEqualTo("inhabitants");
softly.assertThat(nestedMetaData.getChild().getOffset()).isEqualTo(1);
innerHit = innerHits.getSearchHit(1);
softly.assertThat(((Inhabitant) innerHit.getContent()).getLastName()).isEqualTo("Nguyen");
softly.assertThat(innerHit.getNestedMetaData().getChild().getOffset()).isEqualTo(2);
softly.assertAll();
}
@@ -908,6 +908,55 @@ public class MappingElasticsearchConverterUnitTests {
assertEquals(expected, document.toJson(), false);
}
@Test // #2627
@DisplayName("should write Map containing collection containing map")
void shouldWriteMapContainingCollectionContainingMap() throws JSONException {
class EntityWithMapCollectionMap {
Map<String, Object> map;
}
class InnerEntity {
String prop1;
String prop2;
public InnerEntity() {}
public InnerEntity(String prop1, String prop2) {
this.prop1 = prop1;
this.prop2 = prop2;
}
}
var entity = new EntityWithMapCollectionMap();
entity.map = Collections.singletonMap("collection",
Collections.singletonList(Collections.singletonMap("destination", new InnerEntity("prop1", "prop2"))));
var expected = """
{
"_class": "org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverterUnitTests$1EntityWithMapCollectionMap",
"map": {
"collection": [
{
"destination": {
"_class": "org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverterUnitTests$1InnerEntity",
"prop1": "prop1",
"prop2": "prop2"
}
}
]
}
}
""";
Document document = Document.create();
mappingElasticsearchConverter.write(entity, document);
assertEquals(expected, document.toJson(), false);
}
@Nested
class RangeTests {
@@ -37,22 +37,14 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.NewElasticsearchClientDevelopment;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Dynamic;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.InnerField;
import org.springframework.data.elasticsearch.annotations.Mapping;
import org.springframework.data.elasticsearch.annotations.MultiField;
import org.springframework.data.elasticsearch.annotations.Setting;
import org.springframework.data.elasticsearch.annotations.TermVector;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.IndexOperations;
import org.springframework.data.elasticsearch.core.MappingContextBaseTests;
@@ -62,7 +62,7 @@ public abstract class SearchAfterIntegrationTests {
@Test
@Order(java.lang.Integer.MAX_VALUE)
void cleanup() {
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete();
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + '*')).delete();
}
@Test // #1143
@@ -85,11 +85,11 @@ public abstract class SearchAfterIntegrationTests {
query.setSearchAfter(searchAfter);
SearchHits<Entity> searchHits = operations.search(query, Entity.class);
if (searchHits.getSearchHits().size() == 0) {
if (searchHits.getSearchHits().isEmpty()) {
break;
}
foundEntities.addAll(searchHits.stream().map(SearchHit::getContent).collect(Collectors.toList()));
searchAfter = searchHits.getSearchHit((int) (searchHits.getSearchHits().size() - 1)).getSortValues();
foundEntities.addAll(searchHits.stream().map(SearchHit::getContent).toList());
searchAfter = searchHits.getSearchHit(searchHits.getSearchHits().size() - 1).getSortValues();
if (++loop > 10) {
fail("loop not terminating");
@@ -99,16 +99,69 @@ public abstract class SearchAfterIntegrationTests {
assertThat(foundEntities).containsExactlyElementsOf(entities);
}
@Test // #2678
@DisplayName("should be able to handle different search after type values including null")
void shouldBeAbleToHandleDifferentSearchAfterTypeValuesIncludingNull() {
List<Entity> entities = IntStream.rangeClosed(1, 10)
.mapToObj(i -> {
var message = (i % 2 == 0) ? null : "message " + i;
var value = (i % 3 == 0) ? null : (long) i;
return new Entity((long) i, message, value);
})
.collect(Collectors.toList());
operations.save(entities);
Query query = Query.findAll();
query.setPageable(PageRequest.of(0, 3));
query.addSort(Sort.by(Sort.Direction.ASC, "id"));
query.addSort(Sort.by(Sort.Direction.ASC, "keyword"));
query.addSort(Sort.by(Sort.Direction.ASC, "value"));
List<Object> searchAfter = null;
List<Entity> foundEntities = new ArrayList<>();
int loop = 0;
do {
query.setSearchAfter(searchAfter);
SearchHits<Entity> searchHits = operations.search(query, Entity.class);
if (searchHits.getSearchHits().isEmpty()) {
break;
}
foundEntities.addAll(searchHits.stream().map(SearchHit::getContent).toList());
searchAfter = searchHits.getSearchHit(searchHits.getSearchHits().size() - 1).getSortValues();
if (++loop > 10) {
fail("loop not terminating");
}
} while (true);
assertThat(foundEntities).containsExactlyElementsOf(entities);
}
@SuppressWarnings("unused")
@Document(indexName = "#{@indexNameProvider.indexName()}")
private static class Entity {
@Nullable
@Id private Long id;
@Nullable
@Field(type = FieldType.Text) private String message;
@Field(type = FieldType.Keyword) private String keyword;
public Entity(@Nullable Long id, @Nullable String message) {
@Nullable
@Field(type = FieldType.Long) private Long value;
public Entity() {}
public Entity(@Nullable Long id, @Nullable String keyword) {
this.id = id;
this.message = message;
this.keyword = keyword;
}
public Entity(@Nullable Long id, @Nullable String keyword, @Nullable Long value) {
this.id = id;
this.keyword = keyword;
this.value = value;
}
@Nullable
@@ -121,30 +174,44 @@ public abstract class SearchAfterIntegrationTests {
}
@Nullable
public String getMessage() {
return message;
public String getKeyword() {
return keyword;
}
public void setMessage(@Nullable String message) {
this.message = message;
public void setKeyword(@Nullable String keyword) {
this.keyword = keyword;
}
@Nullable
public Long getValue() {
return value;
}
public void setValue(@Nullable Long value) {
this.value = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Entity entity))
if (o == null || getClass() != o.getClass())
return false;
Entity entity = (Entity) o;
if (!Objects.equals(id, entity.id))
return false;
return Objects.equals(message, entity.message);
if (!Objects.equals(keyword, entity.keyword))
return false;
return Objects.equals(value, entity.value);
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (message != null ? message.hashCode() : 0);
result = 31 * result + (keyword != null ? keyword.hashCode() : 0);
result = 31 * result + (value != null ? value.hashCode() : 0);
return result;
}
}
@@ -1590,6 +1590,41 @@ public abstract class CustomMethodRepositoryIntegrationTests implements NewElast
assertThat(searchHits.getSearchHit(2).getId()).isEqualTo("oslo");
}
@Test // #2601
void shouldUseGeoSortReverseParameter() {
GeoPoint munich = new GeoPoint(48.137154, 11.5761247);
GeoPoint berlin = new GeoPoint(52.520008, 13.404954);
GeoPoint vienna = new GeoPoint(48.20849, 16.37208);
GeoPoint oslo = new GeoPoint(59.9127, 10.7461);
List<SampleEntity> entities = new ArrayList<>();
SampleEntity entity1 = new SampleEntity();
entity1.setId("berlin");
entity1.setLocation(berlin);
entities.add(entity1);
SampleEntity entity2 = new SampleEntity();
entity2.setId("vienna");
entity2.setLocation(vienna);
entities.add(entity2);
SampleEntity entity3 = new SampleEntity();
entity3.setId("oslo");
entity3.setLocation(oslo);
entities.add(entity3);
repository.saveAll(entities);
SearchHits<SampleEntity> searchHits = repository
.searchBy(Sort.by(new GeoDistanceOrder("location", munich).with(Sort.Direction.DESC)));
assertThat(searchHits.getTotalHits()).isEqualTo(3);
assertThat(searchHits.getSearchHit(0).getId()).isEqualTo("oslo");
assertThat(searchHits.getSearchHit(1).getId()).isEqualTo("berlin");
assertThat(searchHits.getSearchHit(2).getId()).isEqualTo("vienna");
}
@Test // DATAES-749
void shouldReturnSearchPage() {
List<SampleEntity> entities = createSampleEntities("abc", 20);