mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-24 04:52:12 +00:00
replaced Integer.MAX_VALUE from findAll(Sort sort) with actual count
This commit is contained in:
parent
923273955b
commit
e9eed44b98
@ -95,9 +95,13 @@ public class SimpleElasticsearchRepository<T> implements ElasticsearchRepository
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<T> findAll(Sort sort) {
|
public Iterable<T> findAll(Sort sort) {
|
||||||
|
int itemCount = (int) this.count();
|
||||||
|
if (itemCount == 0) {
|
||||||
|
return new PageImpl<T>(Collections.<T> emptyList());
|
||||||
|
}
|
||||||
SearchQuery query = new SearchQuery();
|
SearchQuery query = new SearchQuery();
|
||||||
query.setElasticsearchQuery(matchAllQuery());
|
query.setElasticsearchQuery(matchAllQuery());
|
||||||
query.setPageable(new PageRequest(0,Integer.MAX_VALUE, sort));
|
query.setPageable(new PageRequest(0,itemCount, sort));
|
||||||
return elasticsearchOperations.queryForPage(query, getEntityClass());
|
return elasticsearchOperations.queryForPage(query, getEntityClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user