-
Notifications
You must be signed in to change notification settings - Fork 143
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
Fix script score queries not getting cached #1367
Fix script score queries not getting cached #1367
Conversation
@junqiu-lei can you add the details on how you tested that script queries are getting cached? |
818715c
to
e91389b
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1367 +/- ##
=========================================
Coverage 85.04% 85.05%
- Complexity 1251 1254 +3
=========================================
Files 162 163 +1
Lines 5101 5104 +3
Branches 477 477
=========================================
+ Hits 4338 4341 +3
Misses 557 557
Partials 206 206 ☔ View full report in Codecov by Sentry. |
@navneet1v We can check the index request_cache stat, finally it will be hit if we enable the request cache. The test steps can be found below:
|
can we use the index stats to validate in the IT that cache is getting hit, this will ensure that in future we are able to catch any issue if the request suddenly stopped caching. |
Yes, the new IT which use index stats to validate is already included in this PR. |
src/main/java/org/opensearch/knn/plugin/script/KNNScoreScriptLeafFactory.java
Outdated
Show resolved
Hide resolved
95e522d
to
a30a6f3
Compare
@@ -39,7 +39,7 @@ public <FactoryType> FactoryType compile(String name, String code, ScriptContext | |||
KNNCounter.SCRIPT_COMPILATION_ERRORS.increment(); | |||
throw new IllegalArgumentException("Unknown script name " + code); | |||
} | |||
ScoreScript.Factory factory = KNNScoreScriptFactory::new; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we need, since KNNScoreScriptFactory does not have a no-argument constructor that matches what's expected by the interface, we can't use the method reference KNNScoreScriptFactory::new
here. And the IDE
will report error "Cannot resolve constructor 'KNNScoreScriptFactory'"
src/main/java/org/opensearch/knn/plugin/script/KNNScoreScriptLeafFactory.java
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/plugin/script/KNNScoreScriptLeafFactory.java
Outdated
Show resolved
Hide resolved
a30a6f3
to
d439b7f
Compare
src/main/java/org/opensearch/knn/plugin/script/KNNScoreScriptLeafFactory.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Junqiu Lei <[email protected]>
d439b7f
to
659824b
Compare
The backport to
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-1367-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 2dc3f613451e6c36fc41a2988081cf5c76490285
# Push it to GitHub
git push --set-upstream origin backport/backport-1367-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 |
Description
This PR fixs the issue when trying perform a Script Score query in k-NN with
request_cache=true
not work as expected.Details on issue debug: #1098 (comment)
Issues Resolved
Closes #1098
Check List
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.