mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-08 21:22:12 +00:00
Pageable results and @Query annotation.
Original Pull Request #1844 Closes #1843
This commit is contained in:
parent
73f11a0618
commit
93cf9ab794
@ -86,6 +86,12 @@ public final class SearchHitSupport {
|
||||
return unwrapSearchHitsIterator((SearchHitsIterator<?>) result);
|
||||
}
|
||||
|
||||
if (result instanceof SearchPage<?>) {
|
||||
SearchPage<?> searchPage = (SearchPage<?>) result;
|
||||
List<?> content = (List<?>) SearchHitSupport.unwrapSearchHits(searchPage.getSearchHits());
|
||||
return new PageImpl<>(content, searchPage.getPageable(), searchPage.getTotalElements());
|
||||
}
|
||||
|
||||
if (ReactiveWrappers.isAvailable(ReactiveWrappers.ReactiveLibrary.PROJECT_REACTOR)) {
|
||||
|
||||
if (result instanceof Flux) {
|
||||
|
@ -126,7 +126,9 @@ public class ElasticsearchPartQuery extends AbstractElasticsearchRepositoryQuery
|
||||
result = elasticsearchOperations.searchOne(query, clazz, index);
|
||||
}
|
||||
|
||||
return queryMethod.isNotSearchHitMethod() ? SearchHitSupport.unwrapSearchHits(result) : result;
|
||||
return (queryMethod.isNotSearchHitMethod() && !queryMethod.isSearchPageMethod())
|
||||
? SearchHitSupport.unwrapSearchHits(result)
|
||||
: result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -151,6 +151,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
// then
|
||||
assertThat(page).isNotNull();
|
||||
assertThat(page.getTotalElements()).isGreaterThanOrEqualTo(1L);
|
||||
assertThat(page.getContent().get(0)).isInstanceOf(SampleEntity.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user