mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-29 15:22:11 +00:00
DATAES-753 - Reactive Elasticsearch repository: Bulk update fails on empty entity list.
Original PR: #398
This commit is contained in:
parent
6a4a7483aa
commit
bf51de3805
@ -88,7 +88,7 @@ public interface ReactiveDocumentOperations {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Index entities under the given {@literal type} in the given {@literal index}. If the {@literal index} is
|
* Index entities under the given {@literal type} in the given {@literal index}. If the {@literal index} is
|
||||||
* {@literal null} or empty the index name provided via entity metadata is used. Same for the {@literal type}.
|
* {@literal null} or empty the index name provided via entity metadata is used.
|
||||||
*
|
*
|
||||||
* @param entities must not be {@literal null}.
|
* @param entities must not be {@literal null}.
|
||||||
* @param index the target index, must not be {@literal null}
|
* @param index the target index, must not be {@literal null}
|
||||||
@ -104,7 +104,7 @@ public interface ReactiveDocumentOperations {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Index entities under the given {@literal type} in the given {@literal index}. If the {@literal index} is
|
* Index entities under the given {@literal type} in the given {@literal index}. If the {@literal index} is
|
||||||
* {@literal null} or empty the index name provided via entity metadata is used. Same for the {@literal type}.
|
* {@literal null} or empty the index name provided via entity metadata is used.
|
||||||
*
|
*
|
||||||
* @param entities must not be {@literal null}.
|
* @param entities must not be {@literal null}.
|
||||||
* @param index the target index, must not be {@literal null}
|
* @param index the target index, must not be {@literal null}
|
||||||
|
@ -160,6 +160,11 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera
|
|||||||
List<AdaptibleEntity<? extends T>> adaptibleEntities = entityList.stream() //
|
List<AdaptibleEntity<? extends T>> adaptibleEntities = entityList.stream() //
|
||||||
.map(e -> operations.forEntity(e, converter.getConversionService())) //
|
.map(e -> operations.forEntity(e, converter.getConversionService())) //
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (adaptibleEntities.isEmpty()) {
|
||||||
|
return Flux.empty();
|
||||||
|
}
|
||||||
|
|
||||||
Iterator<AdaptibleEntity<? extends T>> iterator = adaptibleEntities.iterator();
|
Iterator<AdaptibleEntity<? extends T>> iterator = adaptibleEntities.iterator();
|
||||||
List<IndexQuery> indexRequests = adaptibleEntities.stream() //
|
List<IndexQuery> indexRequests = adaptibleEntities.stream() //
|
||||||
.map(e -> getIndexQuery(e.getBean(), e)) //
|
.map(e -> getIndexQuery(e.getBean(), e)) //
|
||||||
|
@ -811,6 +811,13 @@ public class ReactiveElasticsearchTemplateTests {
|
|||||||
.verifyComplete();
|
.verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // DATAES-753
|
||||||
|
void shouldReturnEmptyFluxOnSaveAllWithEmptyInput() {
|
||||||
|
template.saveAll(Collections.emptyList(), IndexCoordinates.of(DEFAULT_INDEX)) //
|
||||||
|
.as(StepVerifier::create) //
|
||||||
|
.verifyComplete();
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Document(indexName = "marvel")
|
@Document(indexName = "marvel")
|
||||||
static class Person {
|
static class Person {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user