At the moment org.springframework.data.domain.PageRequest
doesn't allow size to be zero, in fact there is a check on this in the AbstractPageRequest
constructor.
So how are we supposed to set the size to zero in a org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder
?
The point being that is possible to set a size of 0 on a org.elasticsearch.action.search.SearchRequestBuilder
. In fact there is a well known use case where one should set the size to zero: "I am just interested in the aggregation result and not in the documents found by the query".
Here is a snapshot of my code which is throwing the IllegalArgumentException
:
SearchQuery searchQuery = (SearchQuery) new NativeSearchQueryBuilder()
.withIndices(indices).withTypes(types)
.withQuery(query).addAggregation(agg)
.withPageable(new PageRequest(0, 0)).build();