Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f70a7d6414 | |||
| 13a4aa31f6 | |||
| aa4aecacdf | |||
| 85ed8a4891 | |||
| ae66cbd619 | |||
| 98d1f5bf63 | |||
| d9f71027b6 | |||
| 2729fa95a3 |
@@ -5,12 +5,12 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-elasticsearch</artifactId>
|
||||
<version>4.4.1</version>
|
||||
<version>4.4.2</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.data.build</groupId>
|
||||
<artifactId>spring-data-parent</artifactId>
|
||||
<version>2.7.1</version>
|
||||
<version>2.7.2</version>
|
||||
</parent>
|
||||
|
||||
<name>Spring Data Elasticsearch</name>
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
<properties>
|
||||
<!-- version of the RestHighLevelClient -->
|
||||
<elasticsearch-rhlc>7.17.3</elasticsearch-rhlc>
|
||||
<elasticsearch-rhlc>7.17.4</elasticsearch-rhlc>
|
||||
<!-- version of the new ElasticsearchClient -->
|
||||
<elasticsearch-java>7.17.3</elasticsearch-java>
|
||||
<elasticsearch-java>7.17.4</elasticsearch-java>
|
||||
<log4j>2.17.1</log4j>
|
||||
<netty>4.1.65.Final</netty>
|
||||
<springdata.commons>2.7.1</springdata.commons>
|
||||
<springdata.commons>2.7.2</springdata.commons>
|
||||
<testcontainers>1.16.2</testcontainers>
|
||||
<blockhound-junit>1.0.6.RELEASE</blockhound-junit>
|
||||
<java-module-name>spring.data.elasticsearch</java-module-name>
|
||||
|
||||
@@ -29,15 +29,18 @@ Requires an installation of https://www.elastic.co/products/elasticsearch[Elasti
|
||||
[[preface.versions]]
|
||||
=== Versions
|
||||
|
||||
The following table shows the Elasticsearch versions that are used by Spring Data release trains and version of Spring Data Elasticsearch included in that, as well as the Spring Boot versions referring to that particular Spring Data release train:
|
||||
The following table shows the Elasticsearch versions that are used by Spring Data release trains and version of
|
||||
Spring Data Elasticsearch included in that, as well as the Spring Boot versions referring to that particular Spring
|
||||
Data release train. The Elasticsearch version given shows with which client libraries Spring Data Elasticsearch was
|
||||
built and tested.
|
||||
|
||||
[cols="^,^,^,^,^",options="header"]
|
||||
|===
|
||||
| Spring Data Release Train | Spring Data Elasticsearch | Elasticsearch | Spring Framework | Spring Boot
|
||||
| 2022.0 (Raj) | 4.4.x | 7.17.3 | 5.3.x | 2.7.x
|
||||
| 2021.2 (Raj) | 4.4.x | 7.17.4 | 5.3.x | 2.7.x
|
||||
| 2021.1 (Q) | 4.3.x | 7.15.2 | 5.3.x | 2.6.x
|
||||
| 2021.0 (Pascal) | 4.2.x | 7.12.0 | 5.3.x | 2.5.x
|
||||
| 2020.0 (Ockham)footnote:oom[Out of maintenance] | 4.1.xfootnote:oom[] | 7.9.3 | 5.3.2 | 2.4.x
|
||||
| 2021.0 (Pascal) | 4.2.xfootnote:oom[Out of maintenance] | 7.12.0 | 5.3.x | 2.5.x
|
||||
| 2020.0 (Ockham)footnote:oom[] | 4.1.xfootnote:oom[] | 7.9.3 | 5.3.2 | 2.4.x
|
||||
| Neumannfootnote:oom[] | 4.0.xfootnote:oom[] | 7.6.2 | 5.2.12 |2.3.x
|
||||
| Moorefootnote:oom[] | 3.2.xfootnote:oom[] |6.8.12 | 5.2.12| 2.2.x
|
||||
| Lovelacefootnote:oom[] | 3.1.xfootnote:oom[] | 6.2.2 | 5.1.19 |2.1.x
|
||||
|
||||
@@ -82,7 +82,7 @@ The dependencies for the new Elasticsearch client are still optional in Spring D
|
||||
<dependency>
|
||||
<groupId>co.elastic.clients</groupId>
|
||||
<artifactId>elasticsearch-java</artifactId>
|
||||
<version>7.17.3</version>
|
||||
<version>7.17.4</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
@@ -93,7 +93,7 @@ The dependencies for the new Elasticsearch client are still optional in Spring D
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch.client</groupId>
|
||||
<artifactId>elasticsearch-rest-client</artifactId> <!-- is Apache 2-->
|
||||
<version>7.17.3</version>
|
||||
<version>7.17.4</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
== New in Spring Data Elasticsearch 4.4
|
||||
|
||||
* Introduction of new imperative and reactive clients using the classes from the new Elasticsearch Java client
|
||||
* Upgrade to Elasticsearch 7.17.3.
|
||||
* Upgrade to Elasticsearch 7.17.4.
|
||||
|
||||
[[new-features.4-3-0]]
|
||||
== New in Spring Data Elasticsearch 4.3
|
||||
|
||||
@@ -1092,8 +1092,7 @@ class RequestFactory {
|
||||
|
||||
public UpdateByQueryRequest updateByQueryRequest(UpdateQuery query, IndexCoordinates index) {
|
||||
|
||||
String indexName = index.getIndexName();
|
||||
final UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(indexName);
|
||||
final UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(index.getIndexNames());
|
||||
updateByQueryRequest.setScript(getScript(query));
|
||||
|
||||
if (query.getAbortOnVersionConflict() != null) {
|
||||
|
||||
+1
-2
@@ -82,8 +82,7 @@ abstract class AbstractReactiveElasticsearchRepositoryQuery implements Repositor
|
||||
|
||||
ResultProcessor processor = queryMethod.getResultProcessor().withDynamicProjection(parameterAccessor);
|
||||
|
||||
Query query = createQuery(
|
||||
new ConvertingParameterAccessor(elasticsearchOperations.getElasticsearchConverter(), parameterAccessor));
|
||||
Query query = createQuery(parameterAccessor);
|
||||
|
||||
if (queryMethod.hasAnnotatedHighlight()) {
|
||||
query.setHighlightQuery(queryMethod.getAnnotatedHighlightQuery());
|
||||
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2022 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.repository.query;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Peter-Josef Meisch
|
||||
* @since 3.2
|
||||
*/
|
||||
public class ConvertingParameterAccessor implements ElasticsearchParameterAccessor {
|
||||
|
||||
private final ElasticsearchConverter converter;
|
||||
private final ElasticsearchParameterAccessor delegate;
|
||||
|
||||
public ConvertingParameterAccessor(ElasticsearchConverter converter, ElasticsearchParameterAccessor delegate) {
|
||||
|
||||
this.converter = converter;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getValues() {
|
||||
return delegate.getValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pageable getPageable() {
|
||||
return delegate.getPageable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sort getSort() {
|
||||
return delegate.getSort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Class<?>> getDynamicProjection() {
|
||||
return delegate.getDynamicProjection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> findDynamicProjection() {
|
||||
return delegate.findDynamicProjection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBindableValue(int index) {
|
||||
return getConvertedValue(delegate.getBindableValue(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBindableNullValue() {
|
||||
return delegate.hasBindableNullValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return delegate.iterator();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object getConvertedValue(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
if (converter.getConversionService().canConvert(value.getClass(), String.class)) {
|
||||
return converter.getConversionService().convert(value, String.class);
|
||||
}
|
||||
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
Spring Data Elasticsearch 4.4.1 (2021.2.1)
|
||||
Spring Data Elasticsearch 4.4.2 (2021.2.2)
|
||||
Copyright (c) [2013-2021] Pivotal Software, Inc.
|
||||
|
||||
This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
||||
@@ -37,5 +37,6 @@ conditions of the subcomponent's license, as noted in the LICENSE file.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -239,7 +239,7 @@ public class ElasticsearchERHLCIntegrationTests extends ElasticsearchIntegration
|
||||
assertThat(fetchSourceContext.excludes()).containsExactlyInAnyOrder("excl");
|
||||
}
|
||||
|
||||
@Test // #1446
|
||||
@Test // #1446, #2191
|
||||
void shouldUseAllOptionsFromUpdateByQuery() throws JSONException {
|
||||
|
||||
Query searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()) //
|
||||
@@ -269,9 +269,10 @@ public class ElasticsearchERHLCIntegrationTests extends ElasticsearchIntegration
|
||||
" }" + " }" + '}';
|
||||
|
||||
// when
|
||||
UpdateByQueryRequest request = getRequestFactory().updateByQueryRequest(updateQuery, IndexCoordinates.of("index"));
|
||||
UpdateByQueryRequest request = getRequestFactory().updateByQueryRequest(updateQuery, IndexCoordinates.of("index1", "index2"));
|
||||
|
||||
// then
|
||||
assertThat(request.indices()).containsExactlyInAnyOrder("index1", "index2");
|
||||
assertThat(request).isNotNull();
|
||||
assertThat(request.getSearchRequest().indicesOptions()).usingRecursiveComparison()
|
||||
.isEqualTo(IndicesOptions.LENIENT_EXPAND_OPEN);
|
||||
|
||||
+45
-1
@@ -144,10 +144,37 @@ public class ReactiveElasticsearchStringQueryUnitTests extends ElasticsearchStri
|
||||
.isEqualTo("{ 'bool' : { 'must' : { 'term' : { 'car' : 'Toyota-Prius' } } } }");
|
||||
}
|
||||
|
||||
@Test // #2135
|
||||
@DisplayName("should handle array-of-strings parameters correctly")
|
||||
void shouldHandleArrayOfStringsParametersCorrectly() throws Exception {
|
||||
|
||||
List<String> otherNames = Arrays.asList("Wesley", "Emmett");
|
||||
|
||||
org.springframework.data.elasticsearch.core.query.Query query = createQuery("findByOtherNames", otherNames);
|
||||
|
||||
assertThat(query).isInstanceOf(StringQuery.class);
|
||||
assertThat(((StringQuery) query).getSource())
|
||||
.isEqualTo("{ 'bool' : { 'must' : { 'terms' : { 'otherNames' : [\"Wesley\",\"Emmett\"] } } } }");
|
||||
}
|
||||
|
||||
@Test // #2135
|
||||
@DisplayName("should handle array-of-Integers parameters correctly")
|
||||
void shouldHandleArrayOfIntegerParametersCorrectly() throws Exception {
|
||||
|
||||
List<Integer> ages = Arrays.asList(42, 57);
|
||||
|
||||
org.springframework.data.elasticsearch.core.query.Query query = createQuery("findByAges", ages);
|
||||
|
||||
assertThat(query).isInstanceOf(StringQuery.class);
|
||||
assertThat(((StringQuery) query).getSource())
|
||||
.isEqualTo("{ 'bool' : { 'must' : { 'terms' : { 'ages' : [42,57] } } } }");
|
||||
}
|
||||
|
||||
private org.springframework.data.elasticsearch.core.query.Query createQuery(String methodName, Object... args)
|
||||
throws NoSuchMethodException {
|
||||
|
||||
Class<?>[] argTypes = Arrays.stream(args).map(Object::getClass).toArray(Class[]::new);
|
||||
Class<?>[] argTypes = Arrays.stream(args).map(Object::getClass)
|
||||
.map(clazz -> Collection.class.isAssignableFrom(clazz) ? List.class : clazz).toArray(Class[]::new);
|
||||
ReactiveElasticsearchQueryMethod queryMethod = getQueryMethod(methodName, argTypes);
|
||||
ReactiveElasticsearchStringQuery elasticsearchStringQuery = queryForMethod(queryMethod);
|
||||
|
||||
@@ -195,6 +222,12 @@ public class ReactiveElasticsearchStringQueryUnitTests extends ElasticsearchStri
|
||||
@Query("{ 'bool' : { 'must' : { 'term' : { 'car' : '?0' } } } }")
|
||||
Mono<Person> findByCar(Car car);
|
||||
|
||||
@Query("{ 'bool' : { 'must' : { 'terms' : { 'otherNames' : ?0 } } } }")
|
||||
Flux<Person> findByOtherNames(List<String> otherNames);
|
||||
|
||||
@Query("{ 'bool' : { 'must' : { 'terms' : { 'ages' : ?0 } } } }")
|
||||
Flux<Person> findByAges(List<Integer> ages);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,6 +244,8 @@ public class ReactiveElasticsearchStringQueryUnitTests extends ElasticsearchStri
|
||||
|
||||
@Nullable private String name;
|
||||
|
||||
@Nullable private List<String> otherNames;
|
||||
|
||||
@Nullable
|
||||
@Field(type = FieldType.Nested) private List<Car> car;
|
||||
|
||||
@@ -235,6 +270,15 @@ public class ReactiveElasticsearchStringQueryUnitTests extends ElasticsearchStri
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getOtherNames() {
|
||||
return otherNames;
|
||||
}
|
||||
|
||||
public void setOtherNames(List<String> otherNames) {
|
||||
this.otherNames = otherNames;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Car> getCar() {
|
||||
return car;
|
||||
|
||||
+179
-72
@@ -63,10 +63,13 @@ import org.springframework.lang.Nullable;
|
||||
@SpringIntegrationTest
|
||||
abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
|
||||
@Autowired ReactiveElasticsearchOperations operations;
|
||||
@Autowired ReactiveSampleEntityRepository repository;
|
||||
@Autowired
|
||||
ReactiveElasticsearchOperations operations;
|
||||
@Autowired
|
||||
ReactiveSampleEntityRepository repository;
|
||||
|
||||
@Autowired private IndexNameProvider indexNameProvider;
|
||||
@Autowired
|
||||
private IndexNameProvider indexNameProvider;
|
||||
|
||||
@BeforeEach
|
||||
void before() {
|
||||
@@ -80,7 +83,8 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete().block();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void saveShouldSaveSingleEntity() {
|
||||
|
||||
repository.save(new SampleEntity()) //
|
||||
@@ -94,7 +98,8 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
return operations.exists(id, IndexCoordinates.of(indexNameProvider.indexName()));
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void saveShouldComputeMultipleEntities() {
|
||||
|
||||
repository.saveAll(Arrays.asList(new SampleEntity(), new SampleEntity(), new SampleEntity()))
|
||||
@@ -107,7 +112,8 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519, DATAES-767, DATAES-822
|
||||
@Test
|
||||
// DATAES-519, DATAES-767, DATAES-822
|
||||
void findByIdShouldErrorIfIndexDoesNotExist() {
|
||||
|
||||
operations.indexOps(SampleEntity.class).delete().block();
|
||||
@@ -117,39 +123,42 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void findShouldRetrieveSingleEntityById() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two"), //
|
||||
new SampleEntity("id-three")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findById("id-two").as(StepVerifier::create)//
|
||||
.consumeNextWith(it -> assertThat(it.getId()).isEqualTo("id-two")) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void findByIdShouldCompleteIfNothingFound() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two"), //
|
||||
new SampleEntity("id-three")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findById("does-not-exist").as(StepVerifier::create) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-720
|
||||
@Test
|
||||
// DATAES-720
|
||||
void findAllShouldReturnAllElements() {
|
||||
// make sure to be above the default page size of the Query interface
|
||||
int count = DEFAULT_PAGE_SIZE * 2;
|
||||
bulkIndex(IntStream.range(1, count + 1) //
|
||||
.mapToObj(it -> new SampleEntity(String.valueOf(it))) //
|
||||
.toArray(SampleEntity[]::new)) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findAll() //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -157,18 +166,20 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void findAllByIdByIdShouldCompleteIfIndexDoesNotExist() {
|
||||
repository.findAllById(Arrays.asList("id-two", "id-two")).as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void findAllByIdShouldRetrieveMatchingDocuments() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two"), //
|
||||
new SampleEntity("id-three")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findAllById(Arrays.asList("id-one", "id-two")) //
|
||||
.as(StepVerifier::create)//
|
||||
@@ -177,26 +188,28 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void findAllByIdShouldCompleteWhenNothingFound() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two"), //
|
||||
new SampleEntity("id-three")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findAllById(Arrays.asList("can't", "touch", "this")) //
|
||||
.as(StepVerifier::create)//
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-717
|
||||
@Test
|
||||
// DATAES-717
|
||||
void shouldReturnFluxOfSearchHit() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "message"), //
|
||||
new SampleEntity("id-three", "message")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.queryAllByMessage("message") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -205,13 +218,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-717
|
||||
@Test
|
||||
// DATAES-717
|
||||
void shouldReturnFluxOfSearchHitForStringQuery() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "message"), //
|
||||
new SampleEntity("id-three", "message")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.queryByMessageWithString("message") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -220,13 +234,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-372
|
||||
@Test
|
||||
// DATAES-372
|
||||
void shouldReturnHighlightsOnAnnotatedMethod() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "message"), //
|
||||
new SampleEntity("id-three", "message")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.queryAllByMessage("message") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -238,13 +253,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-372
|
||||
@Test
|
||||
// DATAES-372
|
||||
void shouldReturnHighlightsOnAnnotatedStringQueryMethod() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "message"), //
|
||||
new SampleEntity("id-three", "message")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.queryByMessageWithString("message") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -256,7 +272,8 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519, DATAES-767, DATAES-822
|
||||
@Test
|
||||
// DATAES-519, DATAES-767, DATAES-822
|
||||
void countShouldErrorWhenIndexDoesNotExist() {
|
||||
|
||||
operations.indexOps(SampleEntity.class).delete().block();
|
||||
@@ -266,23 +283,25 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void countShouldCountDocuments() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.count().as(StepVerifier::create).expectNext(2L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void existsByIdShouldReturnTrueIfExists() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.existsById("id-two") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -290,13 +309,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void existsByIdShouldReturnFalseIfNotExists() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.existsById("wrecking ball") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -304,7 +324,8 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void countShouldCountMatchingDocuments() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
@@ -331,13 +352,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void existsShouldReturnTrueIfExists() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.existsAllByMessage("message") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -345,13 +367,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void existsShouldReturnFalseIfNotExists() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.existsAllByMessage("these days") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -359,24 +382,27 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void deleteByIdShouldCompleteIfNothingDeleted() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.deleteById("does-not-exist").as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519, DATAES-767, DATAES-822, DATAES-678
|
||||
@Test
|
||||
// DATAES-519, DATAES-767, DATAES-822, DATAES-678
|
||||
void deleteByIdShouldCompleteWhenIndexDoesNotExist() {
|
||||
repository.deleteById("does-not-exist") //
|
||||
.as(StepVerifier::create) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void deleteByIdShouldDeleteEntry() {
|
||||
|
||||
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
||||
@@ -388,19 +414,22 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
assertThat(documentWithIdExistsInIndex(toBeDeleted.getId()).block()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAES-976
|
||||
@Test
|
||||
// DATAES-976
|
||||
void deleteAllByIdShouldDeleteEntry() {
|
||||
|
||||
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
||||
bulkIndex(new SampleEntity("id-one"), toBeDeleted) //
|
||||
.block();
|
||||
|
||||
repository.deleteAllById(Collections.singletonList(toBeDeleted.getId())).as(StepVerifier::create).verifyComplete();
|
||||
repository.deleteAllById(Collections.singletonList(toBeDeleted.getId())).as(StepVerifier::create)
|
||||
.verifyComplete();
|
||||
|
||||
assertThat(documentWithIdExistsInIndex(toBeDeleted.getId()).block()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void deleteShouldDeleteEntry() {
|
||||
|
||||
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
||||
@@ -412,7 +441,8 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
assertThat(documentWithIdExistsInIndex(toBeDeleted.getId()).block()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void deleteAllShouldDeleteGivenEntries() {
|
||||
|
||||
SampleEntity toBeDeleted = new SampleEntity("id-one");
|
||||
@@ -429,13 +459,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
assertThat(documentWithIdExistsInIndex(hangInThere.getId()).block()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void deleteAllShouldDeleteAllEntries() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one"), //
|
||||
new SampleEntity("id-two"), //
|
||||
new SampleEntity("id-three")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.deleteAll().as(StepVerifier::create).verifyComplete();
|
||||
|
||||
@@ -445,13 +476,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void derivedFinderMethodShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findAllByMessageLike("test") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -459,13 +491,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void derivedFinderMethodShouldBeExecutedCorrectlyWhenGivenPublisher() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findAllByMessage(Mono.just("test")) //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -473,13 +506,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void derivedFinderWithDerivedSortMethodShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||
new SampleEntity("id-two", "test test", 1), //
|
||||
new SampleEntity("id-three", "test test", 2)) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findAllByMessageLikeOrderByRate("test") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -489,13 +523,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void derivedFinderMethodWithSortParameterShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||
new SampleEntity("id-two", "test test", 1), //
|
||||
new SampleEntity("id-three", "test test", 2)) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findAllByMessage("test", Sort.by(Order.asc("rate"))) //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -505,13 +540,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void derivedFinderMethodWithPageableParameterShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||
new SampleEntity("id-two", "test test", 1), //
|
||||
new SampleEntity("id-three", "test test", 2)) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findAllByMessage("test", PageRequest.of(0, 2, Sort.by(Order.asc("rate")))) //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -520,13 +556,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void derivedFinderMethodReturningMonoShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.findFirstByMessageLike("test") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -534,7 +571,8 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void annotatedFinderMethodShouldBeExecutedCorrectly() {
|
||||
|
||||
int count = 30;
|
||||
@@ -550,7 +588,8 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // #1917
|
||||
@Test
|
||||
// #1917
|
||||
void annotatedFinderMethodPagedShouldBeExecutedCorrectly() {
|
||||
|
||||
int count = 30;
|
||||
@@ -570,13 +609,14 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-519
|
||||
@Test
|
||||
// DATAES-519
|
||||
void derivedDeleteMethodShouldBeExecutedCorrectly() {
|
||||
|
||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||
new SampleEntity("id-two", "test message"), //
|
||||
new SampleEntity("id-three", "test test")) //
|
||||
.block();
|
||||
.block();
|
||||
|
||||
repository.deleteAllByMessage("message") //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -588,6 +628,56 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
assertThat(documentWithIdExistsInIndex("id-three").block()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
// #2135
|
||||
void FluxOfSearchHitForArrayQuery() {
|
||||
bulkIndex(new SampleEntity("id-one", "message1"), //
|
||||
new SampleEntity("id-two", "message2"), //
|
||||
new SampleEntity("id-three", "message3")) //
|
||||
.block();
|
||||
|
||||
repository.findAllViaAnnotatedQueryByMessageIn(Arrays.asList("message1", "message3")) //
|
||||
.as(StepVerifier::create) //
|
||||
.consumeNextWith(it -> assertThat(it.getId()).isEqualTo("id-one")) //
|
||||
.consumeNextWith(it -> assertThat(it.getId()).isEqualTo("id-three")) //
|
||||
.verifyComplete();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
// #2135
|
||||
void FluxOfSearchHitForIntegerArrayQuery() {
|
||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||
new SampleEntity("id-two", "test test", 1), //
|
||||
new SampleEntity("id-three", "test test", 2)) //
|
||||
.block();
|
||||
|
||||
repository.findAllViaAnnotatedQueryByRatesIn(Arrays.asList(2, 3)) //
|
||||
.as(StepVerifier::create) //
|
||||
.consumeNextWith(it -> assertThat(it.getId()).isEqualTo("id-one")) //
|
||||
.consumeNextWith(it -> assertThat(it.getId()).isEqualTo("id-three")) //
|
||||
.verifyComplete();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
// #2135
|
||||
void FluxOfSearchHitForStringAndIntegerArrayQuery() {
|
||||
bulkIndex(new SampleEntity("id-one", "message1", 1), //
|
||||
new SampleEntity("id-two", "message2", 2), //
|
||||
new SampleEntity("id-three", "message3", 3), //
|
||||
new SampleEntity("id-four", "message4", 4), //
|
||||
new SampleEntity("id-five", "message5", 5)) //
|
||||
.block();
|
||||
|
||||
repository.findAllViaAnnotatedQueryByMessageInAndRatesIn(Arrays.asList("message5", "message3"), Arrays.asList(2,
|
||||
3)) //
|
||||
.as(StepVerifier::create) //
|
||||
.consumeNextWith(it -> assertThat(it.getId()).isEqualTo("id-three")) //
|
||||
.verifyComplete();
|
||||
|
||||
}
|
||||
|
||||
Mono<Void> bulkIndex(SampleEntity... entities) {
|
||||
return operations.saveAll(Arrays.asList(entities), IndexCoordinates.of(indexNameProvider.indexName())).then();
|
||||
}
|
||||
@@ -604,11 +694,11 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
|
||||
Flux<SampleEntity> findAllByMessage(Publisher<String> message);
|
||||
|
||||
@Highlight(fields = { @HighlightField(name = "message") })
|
||||
@Highlight(fields = {@HighlightField(name = "message")})
|
||||
Flux<SearchHit<SampleEntity>> queryAllByMessage(String message);
|
||||
|
||||
@Query("{\"bool\": {\"must\": [{\"term\": {\"message\": \"?0\"}}]}}")
|
||||
@Highlight(fields = { @HighlightField(name = "message") })
|
||||
@Highlight(fields = {@HighlightField(name = "message")})
|
||||
Flux<SearchHit<SampleEntity>> queryByMessageWithString(String message);
|
||||
|
||||
@Query("{ \"bool\" : { \"must\" : { \"term\" : { \"message\" : \"?0\" } } } }")
|
||||
@@ -627,22 +717,39 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||
|
||||
@CountQuery(value = "{\"bool\": {\"must\": [{\"term\": {\"message\": \"?0\"}}]}}")
|
||||
Mono<Long> retrieveCountByText(String message);
|
||||
|
||||
@Query("{ \"terms\": { \"message\": ?0 } }")
|
||||
Flux<SampleEntity> findAllViaAnnotatedQueryByMessageIn(List<String> messages);
|
||||
|
||||
@Query("{ \"terms\": { \"rate\": ?0 } }")
|
||||
Flux<SampleEntity> findAllViaAnnotatedQueryByRatesIn(List<Integer> rates);
|
||||
|
||||
@Query("{\"bool\": {\"must\": [{ \"terms\": { \"message\": ?0 } }, { \"terms\": { \"rate\": ?1 } }] } }")
|
||||
Flux<SampleEntity> findAllViaAnnotatedQueryByMessageInAndRatesIn(List<String> messages, List<Integer> rates);
|
||||
|
||||
}
|
||||
|
||||
@Document(indexName = "#{@indexNameProvider.indexName()}")
|
||||
static class SampleEntity {
|
||||
@Nullable
|
||||
@Id private String id;
|
||||
@Id
|
||||
private String id;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Text, store = true, fielddata = true) private String type;
|
||||
@Field(type = FieldType.Text, store = true, fielddata = true)
|
||||
private String type;
|
||||
@Nullable
|
||||
@Field(type = FieldType.Text, store = true, fielddata = true) private String message;
|
||||
@Nullable private int rate;
|
||||
@Nullable private boolean available;
|
||||
@Field(type = FieldType.Text, store = true, fielddata = true)
|
||||
private String message;
|
||||
@Nullable
|
||||
@Version private Long version;
|
||||
private int rate;
|
||||
@Nullable
|
||||
private boolean available;
|
||||
@Nullable
|
||||
@Version
|
||||
private Long version;
|
||||
|
||||
public SampleEntity() {}
|
||||
public SampleEntity() {
|
||||
}
|
||||
|
||||
public SampleEntity(@Nullable String id) {
|
||||
this.id = id;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#
|
||||
#
|
||||
sde.testcontainers.image-name=docker.elastic.co/elasticsearch/elasticsearch
|
||||
sde.testcontainers.image-version=7.17.3
|
||||
sde.testcontainers.image-version=7.17.4
|
||||
#
|
||||
#
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user