mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-09 05:32:11 +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);
|
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 (ReactiveWrappers.isAvailable(ReactiveWrappers.ReactiveLibrary.PROJECT_REACTOR)) {
|
||||||
|
|
||||||
if (result instanceof Flux) {
|
if (result instanceof Flux) {
|
||||||
|
@ -126,7 +126,9 @@ public class ElasticsearchPartQuery extends AbstractElasticsearchRepositoryQuery
|
|||||||
result = elasticsearchOperations.searchOne(query, clazz, index);
|
result = elasticsearchOperations.searchOne(query, clazz, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryMethod.isNotSearchHitMethod() ? SearchHitSupport.unwrapSearchHits(result) : result;
|
return (queryMethod.isNotSearchHitMethod() && !queryMethod.isSearchPageMethod())
|
||||||
|
? SearchHitSupport.unwrapSearchHits(result)
|
||||||
|
: result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -151,6 +151,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
|||||||
// then
|
// then
|
||||||
assertThat(page).isNotNull();
|
assertThat(page).isNotNull();
|
||||||
assertThat(page.getTotalElements()).isGreaterThanOrEqualTo(1L);
|
assertThat(page.getTotalElements()).isGreaterThanOrEqualTo(1L);
|
||||||
|
assertThat(page.getContent().get(0)).isInstanceOf(SampleEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user