Skip to content

DATAES-988 Allow specifying max results in NativeSearchQueryBuilder #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2020
Merged

DATAES-988 Allow specifying max results in NativeSearchQueryBuilder #561

merged 1 commit into from
Nov 30, 2020

Conversation

kilink
Copy link
Contributor

@kilink kilink commented Nov 29, 2020

Add 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 was required before:

NativeSearchQuery searchQuery = NativeSearchQueryBuilder()
.withQuery(matchAllQuery())
.addAggregation(terms("examples").field("example"))
.build();
searchQuery.setMaxResults(0);

@sothawo
Copy link
Collaborator

sothawo commented Nov 29, 2020

Thanks a lot for your PR. Please create a corresponding issue in Jira and reference it in the commit message of your PR.

Add 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 was required before:

NativeSearchQuery searchQuery = NativeSearchQueryBuilder()
        .withQuery(matchAllQuery())
        .addAggregation(terms("examples").field("example"))
        .build();
searchQuery.setMaxResults(0);
@kilink kilink changed the title Allow specifying max results in NativeSearchQueryBuilder DATAES-988 Allow specifying max results in NativeSearchQueryBuilder Nov 30, 2020
@sothawo sothawo merged commit c66443a into spring-projects:master Nov 30, 2020
@sothawo
Copy link
Collaborator

sothawo commented Nov 30, 2020

Thanks again for the contribution, the PR has been merged

@sayantansinha
Copy link

@kilink @sothawo was this released? I am on spring-boot-starter-data-elasticsearch:2.4.5 but don't see this available on NativeSearchQueryBuilder

@sothawo
Copy link
Collaborator

sothawo commented Jun 14, 2022

This was merged in November 2020, so it was then released with Spring Data Elasticsearch 4.2. You'll need at least Spring Boot 2.5.x for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants