Skip to content

[Feature request] Create a GroupingRequest with grouping properties #33605

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

Conversation

yjtakamabe
Copy link
Contributor

Is your feature request related to a problem? Please describe.
The values from the query profile are not reflected when creating a GroupingRequest.

Describe the solution you'd like
We want to create GroupingRequest whose default values are determined by grouping.defaultMaxGroups/ grouping.defaultMaxHits/ grouping.globalMaxGroups/ grouping.defaultPrecisionFactor in the query profile.

Describe alternatives you've considered
We have implemented initProperty and longProperty methods in our container to set the default values in the query profile.

public Result search(Query query, Execution execution) {
    GroupingRequest request = GroupingRequest.newInstance(query);
    intProperty(query, GroupingQueryParser.PARAM_DEFAULT_MAX_GROUPS).ifPresent(request::setDefaultMaxGroups);
    intProperty(query, GroupingQueryParser.PARAM_DEFAULT_MAX_HITS).ifPresent(request::setDefaultMaxHits);
    longProperty(query, GroupingQueryParser.GROUPING_GLOBAL_MAX_GROUPS).ifPresent(request::setGlobalMaxGroups);
    // ...
    // some logic here
    // ...
}

private static OptionalInt intProperty(com.yahoo.search.Query q, CompoundName name) {
    Integer val = q.properties().getInteger(name);
    return val != null ? OptionalInt.of(val) : OptionalInt.empty();
}

private static OptionalLong longProperty(com.yahoo.search.Query q, CompoundName name) {
    Long val = q.properties().getLong(name);
    return val != null ? OptionalLong.of(val) : OptionalLong.empty();
}

Additional context
We cannot use the setDefaultPrecisionFactor method in GroupingRequest because it is package-private.

@yjtakamabe
Copy link
Contributor Author

Please let me know if there's anything I can do to help move it forward or if you have any feedback.
Thank you for your time.

@kkraune kkraune requested a review from bjorncs April 2, 2025 11:20
@bjorncs
Copy link
Member

bjorncs commented Apr 3, 2025

Hi @yjtakamabe. Thanks for your contribution. I will publish my review here shortly.

Copy link
Member

@bjorncs bjorncs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments on newInstanceWithGroupingProperties.

Feel free to change the access modifier of setDefaultPrecisionFactor to public.

Removing extra parameters in GroupingQueryParser.
Move The {int|long|double}Property helpers to GroupingRequest.
Copy link
Member

@bjorncs bjorncs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@bjorncs bjorncs merged commit b91a559 into vespa-engine:master Apr 4, 2025
2 checks passed
@yjtakamabe
Copy link
Contributor Author

Thank you for approving my contribution.

@yjtakamabe yjtakamabe deleted the grouping-request-with-grouping-properties branch April 4, 2025 11:32
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.

2 participants