Skip to content
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

Update pagination_depth datatype from int to Integer #1094

Merged
merged 3 commits into from
Jan 14, 2025

Conversation

vibrantvarun
Copy link
Member

Description

This PR changes pagination_depth datatype from int to Integer. We are doing as the current code is breaking the bwc on 2.x by sending pagination_depth in the older versions of Opensearch.

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Varun Jain <varunudr@amazon.com>
@vibrantvarun
Copy link
Member Author

@martin-gaievski and @heemin32 Please review the PR. Thanks

@@ -109,8 +109,8 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
queryBuilder.toXContent(builder, params);
}
builder.endArray();
if (isClusterOnOrAfterMinReqVersionForPaginationInHybridQuery()) {
Copy link
Member

Choose a reason for hiding this comment

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

do we still need method isClusterOnOrAfterMinReqVersionForPaginationInHybridQuery in MinClusterVersionUtil? Looks like you're using isClusterOnOrAfterMinReqVersionForPaginationInHybridQuery == false and paginationDepth == null interchangeably

Copy link
Member Author

Choose a reason for hiding this comment

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

So how this works is older versions of OS when there is no pagination_depth sent then we will not set that field in the builder object. But when the same method runs for version>=2.19 then in the fromXContent method we give default value 10 when we don't get pagination_depth by the user.

Copy link
Member

Choose a reason for hiding this comment

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

in this case it's a combination of the version check and values being not null. Should you do OR of two? What I'm essentially trying to say - we are checking one condition in one place and another condition in another scenario, and it's not that great.

Copy link
Member Author

Choose a reason for hiding this comment

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

The thing is we do not use isClusterOnOrAfterMinReqVersionForPaginationInHybridQuery in doXContent of any other query builder. Every other place we use the same non null check. Recently expandNested param has been added by heemin in the neuralquerybuilder and it also follow the same non null check.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will address this in #1097

Signed-off-by: Varun Jain <varunudr@amazon.com>
@@ -78,7 +78,7 @@ public HybridQueryBuilder(StreamInput in) throws IOException {
protected void doWriteTo(StreamOutput out) throws IOException {
writeQueries(out, queries);
if (isClusterOnOrAfterMinReqVersionForPaginationInHybridQuery()) {
out.writeInt(paginationDepth);
out.writeOptionalInt(paginationDepth);
Copy link
Member

@ryanbogan ryanbogan Jan 14, 2025

Choose a reason for hiding this comment

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

I ran into a similar error as this with the StreamOutput on k-NN. Using out.getVersion() to see what version you're writing to might help avoid null checks elsewhere. StreamInput has a similar method too so you can set a default for the value.

Example: https://github.com/opensearch-project/k-NN/blob/main/src/main/java/org/opensearch/knn/indices/ModelMetadata.java#L502

Copy link
Member Author

Choose a reason for hiding this comment

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

I will address this in #1097

@vibrantvarun
Copy link
Member Author

We need to merge this PR for now to unblock merging on 2.x
cc: @ryanbogan @martin-gaievski

Signed-off-by: Varun Jain <varunudr@amazon.com>
Copy link
Member

@martin-gaievski martin-gaievski left a comment

Choose a reason for hiding this comment

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

looks good to me, thank you Varun

@martin-gaievski martin-gaievski merged commit bff857d into opensearch-project:main Jan 14, 2025
37 of 39 checks passed
@martin-gaievski martin-gaievski added the backport 2.x Label will add auto workflow to backport PR to 2.x branch label Jan 14, 2025
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1094-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 bff857d6b2995f5a80d54a02af54be42fe90d5f3
# Push it to GitHub
git push --set-upstream origin backport/backport-1094-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-1094-to-2.x.

vibrantvarun added a commit to vibrantvarun/neural-search that referenced this pull request Jan 14, 2025
…ect#1094)

* Update pagination_depth datatype from int to Integer

Signed-off-by: Varun Jain <varunudr@amazon.com>
vibrantvarun added a commit that referenced this pull request Jan 14, 2025
* Pagination in Hybrid query (#1048)

* Pagination in Hybrid query

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Remove unwanted code

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Adding hybrid query context dto

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Adding javadoc in hybridquerycontext and addressing few comments from review

Signed-off-by: Varun Jain <varunudr@amazon.com>

* rename hybrid query extraction method

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Refactoring to optimize extractHybridQuery method calls

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Changes in tests to adapt  with builder pattern in querybuilder

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Add mapper service mock in tests

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Fix error message of index.max_result_window setting

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Fix error message of index.max_result_window setting

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Fixing validation condition for lower bound

Signed-off-by: Varun Jain <varunudr@amazon.com>

* fix tests

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Removing version check from doEquals and doHashCode method

Signed-off-by: Varun Jain <varunudr@amazon.com>

---------

Signed-off-by: Varun Jain <varunudr@amazon.com>

* Update pagination_depth datatype from int to Integer (#1094)

* Update pagination_depth datatype from int to Integer

Signed-off-by: Varun Jain <varunudr@amazon.com>

---------

Signed-off-by: Varun Jain <varunudr@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Label will add auto workflow to backport PR to 2.x branch skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants