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

Changes NativeEngineKNNQuery to execute search and rescore in createWeight phase #2014

Merged

Conversation

shatejas
Copy link
Collaborator

rewrite is executed in QueryPhase and FetchPhase in opensearch, this increases the query latency. As an alternative, the search logic is moved to createWeight phase. This will only be used when there is a rescore context present, as a result this will only execute when the mode is set to on-disk

Screenshot 2024-08-26 at 9 45 41 AM

Check List

  • New functionality includes testing.
  • Commits are signed per the DCO using --signoff.

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.

Sorry, something went wrong.

@@ -96,7 +95,7 @@ public static Query create(CreateQueryRequest createQueryRequest) {
.rescoreContext(rescoreContext)
.build();
}
return isKnnQueryRewriteEnabled() ? new NativeEngineKnnVectorQuery(knnQuery) : knnQuery;
return createQueryRequest.getRescoreContext().isPresent() ? new NativeEngineKnnVectorQuery(knnQuery) : knnQuery;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jmazanec15 Please verify this condition is correct

Copy link
Member

Choose a reason for hiding this comment

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

yeah this looks good

@shatejas shatejas force-pushed the query-create-weight branch from d49e840 to 01be393 Compare August 30, 2024 02:43
createWeight phase

rewrite is executed in QueryPhase and FetchPhase in opensearch,
this increases the query latency. As an alternative, the search logic
is moved to createWeight phase. This will only be used when there is
a rescore context present, as a result this will only execute when
the mode is set to on-disk

Signed-off-by: Tejas Shah <shatejas@amazon.com>
@shatejas shatejas force-pushed the query-create-weight branch from 01be393 to c34c277 Compare August 30, 2024 02:48
@@ -39,8 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* Refactor method structure and definitions [#1920](https://github.com/opensearch-project/k-NN/pull/1920)
* Refactor KNNVectorFieldType from KNNVectorFieldMapper to a separate class for better readability. [#1931](https://github.com/opensearch-project/k-NN/pull/1931)
* Generalize lib interface to return context objects [#1925](https://github.com/opensearch-project/k-NN/pull/1925)
* Move k search k-NN query to re-write phase of vector search query for Native Engines [#1877](https://github.com/opensearch-project/k-NN/pull/1877)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removing this, the change is now covered in the log above

k-NN query rescore support for native engines [#1984](https://github.com/opensearch-project/k-NN/pull/1984)

Copy link
Member

@jmazanec15 jmazanec15 left a comment

Choose a reason for hiding this comment

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

LGTM

@naveentatikonda naveentatikonda merged commit 9dbe7de into opensearch-project:main Aug 30, 2024
28 of 29 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-2014-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 9dbe7de078616da9d95c27883c468c4ef4b7df4a
# Push it to GitHub
git push --set-upstream origin backport/backport-2014-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-2014-to-2.x.

@naveentatikonda
Copy link
Member

@shatejas backport to 2.x failed. Can you fix it and raise a PR. Thanks!

shatejas added a commit to shatejas/k-NN that referenced this pull request Aug 30, 2024
…arch-project#2014)

createWeight phase

rewrite is executed in QueryPhase and FetchPhase in opensearch,
this increases the query latency. As an alternative, the search logic
is moved to createWeight phase. This will only be used when there is
a rescore context present, as a result this will only execute when
the mode is set to on-disk

Signed-off-by: Tejas Shah <shatejas@amazon.com>
(cherry picked from commit 9dbe7de)
@shatejas shatejas deleted the query-create-weight branch August 30, 2024 17:13
naveentatikonda pushed a commit that referenced this pull request Aug 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
akashsha1 pushed a commit to akashsha1/k-NN that referenced this pull request Sep 16, 2024
…arch-project#2014)

createWeight phase

rewrite is executed in QueryPhase and FetchPhase in opensearch,
this increases the query latency. As an alternative, the search logic
is moved to createWeight phase. This will only be used when there is
a rescore context present, as a result this will only execute when
the mode is set to on-disk

Signed-off-by: Tejas Shah <shatejas@amazon.com>
Signed-off-by: Akash Shankaran <akash.shankaran@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants