Description
Patrick Strawderman opened DATAES-988 and commented
It would be useful to have a "withMaxResults" method to NativeSearchQueryBuilder for specifying the maxResults on the built Query. This is common for aggregation queries where search hits are not needed.
Having the builder method for setting maxResults is a minor ergonomic improvement, e.g.
NativeSearchQuery searchQuery = NativeSearchQueryBuilder()
.withQuery(matchAllQuery())
.addAggregation(terms("examples").field("example"))
.withMaxResults(0)
.build();
versus what is required now:
NativeSearchQuery searchQuery = NativeSearchQueryBuilder()
.withQuery(matchAllQuery())
.addAggregation(terms("examples").field("example"))
.build();
searchQuery.setMaxResults(0);
Referenced from: pull request #561