-
Notifications
You must be signed in to change notification settings - Fork 73
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
Check if indices exist in the presence of empty search results #495
Conversation
Previously, CompositeRetriever throws an IllegalArgumentException in the presence of empty results, which gets translated to internal failure and increments AD failure count. When the source index is a regex like blah*, we will get an empty response even if the index does not exist. This PR checks indices exist in the presence of empty search results. If yes, we throw an IndexNotFoundException that ends up being converted to EndRunException; if no, we still throw an IllegalArgumentException. Testing done: 1. added unit tests 2. reproduced manually and verified the change fixed the issue. Signed-off-by: Kaituo Li <[email protected]>
* 2) next detection interval has not started | ||
* @return true if the iteration has more pages. | ||
*/ | ||
public boolean hasNext() { | ||
return (totalResults == 0 || (totalResults > 0 && afterKey != null)) && expirationEpochMs > clock.millis(); | ||
return (iterations == 0 || (totalResults > 0 && afterKey != null)) && expirationEpochMs > clock.millis(); |
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.
Is it possible iterations == 0
and afterKey == null
? Not sure if this is enough afterKey != null && expirationEpochMs > clock.millis()
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.
Is it possible iterations == 0 and afterKey == null
It is possible.
afterKey != null && expirationEpochMs > clock.millis()
This is not enough as at the beginning afterKey = null.
src/test/java/org/opensearch/ad/transport/MultiEntityResultTests.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Kaituo Li <[email protected]>
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.
Thanks for making this fix!
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.
LGTM.
Signed-off-by: Kaituo Li <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #495 +/- ##
============================================
+ Coverage 78.14% 78.20% +0.06%
- Complexity 4155 4162 +7
============================================
Files 296 296
Lines 17654 17663 +9
Branches 1877 1878 +1
============================================
+ Hits 13795 13814 +19
+ Misses 2963 2954 -9
+ Partials 896 895 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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-1.x 1.x
# Navigate to the new working tree
cd .worktrees/backport-1.x
# Create a new branch
git switch --create backport/backport-495-to-1.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 9d44f1bad1bd674c8a03b2629ababab21783f2f3
# Push it to GitHub
git push --set-upstream origin backport/backport-495-to-1.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.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-1.3 1.3
# Navigate to the new working tree
cd .worktrees/backport-1.3
# Create a new branch
git switch --create backport/backport-495-to-1.3
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 9d44f1bad1bd674c8a03b2629ababab21783f2f3
# Push it to GitHub
git push --set-upstream origin backport/backport-495-to-1.3
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.3 Then, create a pull request where the |
…rch results (opensearch-project#495) * Check if indices exist in the presence of empty search results Previously, CompositeRetriever throws an IllegalArgumentException in the presence of empty results, which gets translated to internal failure and increments AD failure count. When the source index is a regex like blah*, we will get an empty response even if the index does not exist. This PR checks indices exist in the presence of empty search results. If yes, we throw an IndexNotFoundException that ends up being converted to EndRunException; if no, we still throw an IllegalArgumentException. Testing done: 1. added unit tests 2. reproduced manually and verified the change fixed the issue. Signed-off-by: Kaituo Li <[email protected]>
…rch results (#495) (#522) * Check if indices exist in the presence of empty search results Previously, CompositeRetriever throws an IllegalArgumentException in the presence of empty results, which gets translated to internal failure and increments AD failure count. When the source index is a regex like blah*, we will get an empty response even if the index does not exist. This PR checks indices exist in the presence of empty search results. If yes, we throw an IndexNotFoundException that ends up being converted to EndRunException; if no, we still throw an IllegalArgumentException. Testing done: 1. added unit tests 2. reproduced manually and verified the change fixed the issue. Signed-off-by: Kaituo Li <[email protected]>
Description
Previously, CompositeRetriever throws an IllegalArgumentException in the presence of empty results, which gets translated to internal failure and increments AD failure count. When the source index is a regex like blah*, we will get an empty response even if the index does not exist. This PR checks indices exist in the presence of empty search results. If yes, we throw an IndexNotFoundException that ends up being converted to EndRunException; if no, we still throw an IllegalArgumentException.
Testing done:
Signed-off-by: Kaituo Li [email protected]
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.