DATAES-720 - SimpleReactiveElasticsearchRepository findAll() returns only 10 elements.

Original PR: #364

(cherry picked from commit b634f318abe771b98d01bc38a3885ffb20e5368f)
This commit is contained in:
Peter-Josef Meisch 2019-12-25 11:01:51 +01:00
parent 283b27d170
commit 6eda05ddd7
2 changed files with 20 additions and 3 deletions

View File

@ -19,6 +19,7 @@ import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.reactivestreams.Publisher;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
import org.springframework.data.elasticsearch.core.query.Query;
@ -47,8 +48,8 @@ public class SimpleReactiveElasticsearchRepository<T, ID> implements ReactiveEla
@Override
public Flux<T> findAll(Sort sort) {
return elasticsearchOperations.find(Query.findAll().addSort(sort), entityInformation.getJavaType(),
entityInformation.getIndexName(), entityInformation.getType());
return elasticsearchOperations.find(Query.findAll().addSort(sort).setPageable(Pageable.unpaged()),
entityInformation.getJavaType(), entityInformation.getIndexName(), entityInformation.getType());
}
@Override
@ -105,7 +106,7 @@ public class SimpleReactiveElasticsearchRepository<T, ID> implements ReactiveEla
@Override
public Flux<T> findAll() {
return elasticsearchOperations.find(Query.findAll(), entityInformation.getJavaType(),
return elasticsearchOperations.find(Query.findAll().setPageable(Pageable.unpaged()), entityInformation.getJavaType(),
entityInformation.getIndexName(), entityInformation.getType());
}

View File

@ -17,6 +17,7 @@ package org.springframework.data.elasticsearch.repository.support;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
import static org.springframework.data.elasticsearch.core.query.Query.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -33,6 +34,7 @@ import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import java.util.stream.IntStream;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.index.IndexRequest;
@ -153,6 +155,20 @@ public class SimpleReactiveElasticsearchRepositoryTests {
.verifyComplete();
}
@Test // DATAES-720
public 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 -> SampleEntity.builder().id(String.valueOf(it)).build()) //
.toArray(SampleEntity[]::new));
repository.findAll() //
.as(StepVerifier::create) //
.expectNextCount(count) //
.verifyComplete();
}
@Test // DATAES-519
public void findAllByIdByIdShouldCompleteIfIndexDoesNotExist() {
repository.findAllById(Arrays.asList("id-two", "id-two")).as(StepVerifier::create).verifyComplete();