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
|
||||
* {@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 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
|
||||
* {@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 index the target index, must not be {@literal null}
|
||||
@ -228,7 +228,7 @@ public interface ReactiveDocumentOperations {
|
||||
* @param entity must not be {@literal null}.
|
||||
* @return a {@link Mono} emitting the {@literal id} of the removed document.
|
||||
*/
|
||||
Mono<String> delete(Object entity);
|
||||
Mono<String> delete(Object entity);
|
||||
|
||||
/**
|
||||
* Delete the given entity extracting index and type from entity metadata.
|
||||
@ -237,7 +237,7 @@ public interface ReactiveDocumentOperations {
|
||||
* @param index the target index, must not be {@literal null}
|
||||
* @return a {@link Mono} emitting the {@literal id} of the removed document.
|
||||
*/
|
||||
Mono<String> delete(Object entity, IndexCoordinates index);
|
||||
Mono<String> delete(Object entity, IndexCoordinates index);
|
||||
|
||||
/**
|
||||
* Delete the entity with given {@literal id}.
|
||||
|
@ -160,6 +160,11 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera
|
||||
List<AdaptibleEntity<? extends T>> adaptibleEntities = entityList.stream() //
|
||||
.map(e -> operations.forEntity(e, converter.getConversionService())) //
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (adaptibleEntities.isEmpty()) {
|
||||
return Flux.empty();
|
||||
}
|
||||
|
||||
Iterator<AdaptibleEntity<? extends T>> iterator = adaptibleEntities.iterator();
|
||||
List<IndexQuery> indexRequests = adaptibleEntities.stream() //
|
||||
.map(e -> getIndexQuery(e.getBean(), e)) //
|
||||
@ -366,7 +371,7 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera
|
||||
* @see org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations#delete(Object, String, String)
|
||||
*/
|
||||
@Override
|
||||
public Mono<String> delete(Object entity, IndexCoordinates index) {
|
||||
public Mono<String> delete(Object entity, IndexCoordinates index) {
|
||||
|
||||
Entity<?> elasticsearchEntity = operations.forEntity(entity);
|
||||
|
||||
|
@ -811,6 +811,13 @@ public class ReactiveElasticsearchTemplateTests {
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAES-753
|
||||
void shouldReturnEmptyFluxOnSaveAllWithEmptyInput() {
|
||||
template.saveAll(Collections.emptyList(), IndexCoordinates.of(DEFAULT_INDEX)) //
|
||||
.as(StepVerifier::create) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "marvel")
|
||||
static class Person {
|
||||
|
Loading…
x
Reference in New Issue
Block a user