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

Pagination in Hybrid query #1048

Merged
merged 19 commits into from
Jan 11, 2025

Conversation

vibrantvarun
Copy link
Member

@vibrantvarun vibrantvarun commented Dec 31, 2024

Description

This PR contains changes for enabling support for pagination in hybrid query.
The highlight of this PR are

  1. Introduction of a new parameter "pagination_depth" to set a reference of hybrid query search results on which pagination can be applied.
  2. Handling of single shard scenario where fetch phase can run before the normalization process.
  3. Handling of from parameter conditions in Normalization processor.
  4. Disabling scroll operation in hybrid query.

Related Issues

#280

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.

@vibrantvarun
Copy link
Member Author

Integ test and BWC tests are failing due to opensearch-project/ml-commons#3321

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.

minor changes requested, overall code looks good to me

@@ -78,16 +73,9 @@ private QueryPhaseSearcher getQueryPhaseSearcher(final SearchContext searchConte
: defaultQueryPhaseSearcherWithEmptyCollectorContext;
}

private static boolean isWrappedHybridQuery(final Query query) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Duplicate method in HybridQueryUtil so removed it

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.

great work Varun, approving

CHANGELOG.md Outdated Show resolved Hide resolved
Signed-off-by: Varun Jain <[email protected]>
Copy link
Member

@VijayanB VijayanB left a comment

Choose a reason for hiding this comment

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

LGTM

@vibrantvarun vibrantvarun merged commit b084838 into opensearch-project:main Jan 11, 2025
39 checks passed
@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-1048-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 b084838490ad90f8715c0b465f08eca62623c74f
# Push it to GitHub
git push --set-upstream origin backport/backport-1048-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-1048-to-2.x.

vibrantvarun added a commit to vibrantvarun/neural-search that referenced this pull request Jan 13, 2025
* Pagination in Hybrid query

Signed-off-by: Varun Jain <[email protected]>

* Remove unwanted code

Signed-off-by: Varun Jain <[email protected]>

* Adding hybrid query context dto

Signed-off-by: Varun Jain <[email protected]>

* Adding javadoc in hybridquerycontext and addressing few comments from review

Signed-off-by: Varun Jain <[email protected]>

* rename hybrid query extraction method

Signed-off-by: Varun Jain <[email protected]>

* Refactoring to optimize extractHybridQuery method calls

Signed-off-by: Varun Jain <[email protected]>

* Changes in tests to adapt  with builder pattern in querybuilder

Signed-off-by: Varun Jain <[email protected]>

* Add mapper service mock in tests

Signed-off-by: Varun Jain <[email protected]>

* Fix error message of index.max_result_window setting

Signed-off-by: Varun Jain <[email protected]>

* Fix error message of index.max_result_window setting

Signed-off-by: Varun Jain <[email protected]>

* Fixing validation condition for lower bound

Signed-off-by: Varun Jain <[email protected]>

* fix tests

Signed-off-by: Varun Jain <[email protected]>

* Removing version check from doEquals and doHashCode method

Signed-off-by: Varun Jain <[email protected]>

---------

Signed-off-by: Varun Jain <[email protected]>
@vibrantvarun vibrantvarun mentioned this pull request Jan 13, 2025
vibrantvarun added a commit to vibrantvarun/neural-search that referenced this pull request Jan 14, 2025
* Pagination in Hybrid query

Signed-off-by: Varun Jain <[email protected]>

* Remove unwanted code

Signed-off-by: Varun Jain <[email protected]>

* Adding hybrid query context dto

Signed-off-by: Varun Jain <[email protected]>

* Adding javadoc in hybridquerycontext and addressing few comments from review

Signed-off-by: Varun Jain <[email protected]>

* rename hybrid query extraction method

Signed-off-by: Varun Jain <[email protected]>

* Refactoring to optimize extractHybridQuery method calls

Signed-off-by: Varun Jain <[email protected]>

* Changes in tests to adapt  with builder pattern in querybuilder

Signed-off-by: Varun Jain <[email protected]>

* Add mapper service mock in tests

Signed-off-by: Varun Jain <[email protected]>

* Fix error message of index.max_result_window setting

Signed-off-by: Varun Jain <[email protected]>

* Fix error message of index.max_result_window setting

Signed-off-by: Varun Jain <[email protected]>

* Fixing validation condition for lower bound

Signed-off-by: Varun Jain <[email protected]>

* fix tests

Signed-off-by: Varun Jain <[email protected]>

* Removing version check from doEquals and doHashCode method

Signed-off-by: Varun Jain <[email protected]>

---------

Signed-off-by: Varun Jain <[email protected]>
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 <[email protected]>

* Remove unwanted code

Signed-off-by: Varun Jain <[email protected]>

* Adding hybrid query context dto

Signed-off-by: Varun Jain <[email protected]>

* Adding javadoc in hybridquerycontext and addressing few comments from review

Signed-off-by: Varun Jain <[email protected]>

* rename hybrid query extraction method

Signed-off-by: Varun Jain <[email protected]>

* Refactoring to optimize extractHybridQuery method calls

Signed-off-by: Varun Jain <[email protected]>

* Changes in tests to adapt  with builder pattern in querybuilder

Signed-off-by: Varun Jain <[email protected]>

* Add mapper service mock in tests

Signed-off-by: Varun Jain <[email protected]>

* Fix error message of index.max_result_window setting

Signed-off-by: Varun Jain <[email protected]>

* Fix error message of index.max_result_window setting

Signed-off-by: Varun Jain <[email protected]>

* Fixing validation condition for lower bound

Signed-off-by: Varun Jain <[email protected]>

* fix tests

Signed-off-by: Varun Jain <[email protected]>

* Removing version check from doEquals and doHashCode method

Signed-off-by: Varun Jain <[email protected]>

---------

Signed-off-by: Varun Jain <[email protected]>

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

* Update pagination_depth datatype from int to Integer

Signed-off-by: Varun Jain <[email protected]>

---------

Signed-off-by: Varun Jain <[email protected]>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants