-
Notifications
You must be signed in to change notification settings - Fork 135
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
add initial MLInferenceSearchResponseProcessor #2688
add initial MLInferenceSearchResponseProcessor #2688
Conversation
Signed-off-by: Mingshi Liu <[email protected]>
f8edd8c
to
7438c2d
Compare
Signed-off-by: Mingshi Liu <[email protected]>
7438c2d
to
cc56fc4
Compare
Signed-off-by: Mingshi Liu <[email protected]>
* @param responseListener the listener to be notified when the response is processed | ||
* @throws IOException if an I/O error occurs during the rewriting process | ||
*/ | ||
private void rewriteResponseDocuments(SearchResponse response, SearchHit[] hits, ActionListener<SearchResponse> responseListener) |
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.
Why do we pass both response and hits? I think response already includes hits.
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.
I need the response here when there is any failure in rewrite, it directly returns the original response
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.
So remove hits? The response has hits.
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.
removed!
try { | ||
SearchHit[] hits = response.getHits().getHits(); | ||
// skip processing when there is no hit | ||
if (hits.length == 0) { |
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.
Check if hits is null first? According to my below comment, maybe
if (response.getHits().getHits() == null || response.getHits().getHits().length == 0)
,
then
rewriteResponseDocuments(response, responseListener)
?
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.
when the hits is null but not empty, it should throw exception and we catch it by ignoreFailure flag, if ignoreFailure is false, it will throw exception accordingly. A valid search response with not matching any document is like this
An empty hit when hits.length == 0, we skip processing the ml inference here.
{
"took": 45,
"timed_out": false,
"_shards": {
"total": 404,
"successful": 404,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 0,
"relation": "eq"
},
"max_score": null,
"hits": []
}
}
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.
if ignoreFailure is false, it will throw exception accordingly.
So in this case we will show "Null pointer exception" to the customer? Does this sound reasonable to customer to get a null pointer exception and having no clue what exactly happened?
resolved merge conflict |
Signed-off-by: Mingshi Liu <[email protected]>
plugin/src/main/java/org/opensearch/ml/processor/MLInferenceSearchResponseProcessor.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/org/opensearch/ml/processor/ModelExecutor.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Mingshi Liu <[email protected]>
All Build and Test CI passed. can you please approve again? @b4sjoo @Zhangxunmt |
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-2688-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 01084b4a014e1cd355cee3d4f45a986b5001681f
# Push it to GitHub
git push --set-upstream origin backport/backport-2688-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 |
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.16 2.16
# Navigate to the new working tree
cd .worktrees/backport-2.16
# Create a new branch
git switch --create backport/backport-2688-to-2.16
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 01084b4a014e1cd355cee3d4f45a986b5001681f
# Push it to GitHub
git push --set-upstream origin backport/backport-2688-to-2.16
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.16 Then, create a pull request where the |
* add MLInferenceSearchResponseProcessor Signed-off-by: Mingshi Liu <[email protected]> * add ITs Signed-off-by: Mingshi Liu <[email protected]> * add code coverage Signed-off-by: Mingshi Liu <[email protected]> * add many_to_one flag Signed-off-by: Mingshi Liu <[email protected]> * avoid import * Signed-off-by: Mingshi Liu <[email protected]> * remove extra hits Signed-off-by: Mingshi Liu <[email protected]> * spotlessApply Signed-off-by: Mingshi Liu <[email protected]> * remove extra brackets Signed-off-by: Mingshi Liu <[email protected]> --------- Signed-off-by: Mingshi Liu <[email protected]> (cherry picked from commit 01084b4)
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-2688-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 01084b4a014e1cd355cee3d4f45a986b5001681f
# Push it to GitHub
git push --set-upstream origin backport/backport-2688-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 |
* add MLInferenceSearchResponseProcessor Signed-off-by: Mingshi Liu <[email protected]> * add ITs Signed-off-by: Mingshi Liu <[email protected]> * add code coverage Signed-off-by: Mingshi Liu <[email protected]> * add many_to_one flag Signed-off-by: Mingshi Liu <[email protected]> * avoid import * Signed-off-by: Mingshi Liu <[email protected]> * remove extra hits Signed-off-by: Mingshi Liu <[email protected]> * spotlessApply Signed-off-by: Mingshi Liu <[email protected]> * remove extra brackets Signed-off-by: Mingshi Liu <[email protected]> --------- Signed-off-by: Mingshi Liu <[email protected]> (cherry picked from commit 01084b4)
* add initial MLInferenceSearchResponseProcessor (#2688) * add MLInferenceSearchResponseProcessor Signed-off-by: Mingshi Liu <[email protected]> * add ITs Signed-off-by: Mingshi Liu <[email protected]> * add code coverage Signed-off-by: Mingshi Liu <[email protected]> * add many_to_one flag Signed-off-by: Mingshi Liu <[email protected]> * avoid import * Signed-off-by: Mingshi Liu <[email protected]> * remove extra hits Signed-off-by: Mingshi Liu <[email protected]> * spotlessApply Signed-off-by: Mingshi Liu <[email protected]> * remove extra brackets Signed-off-by: Mingshi Liu <[email protected]> --------- Signed-off-by: Mingshi Liu <[email protected]> (cherry picked from commit 01084b4) * fix http package Signed-off-by: Mingshi Liu <[email protected]> --------- Signed-off-by: Mingshi Liu <[email protected]> Co-authored-by: Mingshi Liu <[email protected]>
* add initial MLInferenceSearchResponseProcessor (#2688) * add MLInferenceSearchResponseProcessor Signed-off-by: Mingshi Liu <[email protected]> * add ITs Signed-off-by: Mingshi Liu <[email protected]> * add code coverage Signed-off-by: Mingshi Liu <[email protected]> * add many_to_one flag Signed-off-by: Mingshi Liu <[email protected]> * avoid import * Signed-off-by: Mingshi Liu <[email protected]> * remove extra hits Signed-off-by: Mingshi Liu <[email protected]> * spotlessApply Signed-off-by: Mingshi Liu <[email protected]> * remove extra brackets Signed-off-by: Mingshi Liu <[email protected]> --------- Signed-off-by: Mingshi Liu <[email protected]> (cherry picked from commit 01084b4) * fix http package Signed-off-by: Mingshi Liu <[email protected]> --------- Signed-off-by: Mingshi Liu <[email protected]> Co-authored-by: Mingshi Liu <[email protected]>
Description
add initial MLInferenceSearchResponseProcessor
this PR only support collecting many document field in a list to add in one prediction call.
The one document to one prediction call will add incrementally in a next PR
Issues Resolved
#2173
#2444
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.