-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Correct search_after handling #50629
Correct search_after handling #50629
Conversation
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.
Good catch! Left some suggestions.
// TODO: finalize the endpoints | ||
controller.registerHandler(GET, "/{index}/_eql/search", this); | ||
controller.registerHandler(POST, "/{index}/_eql/search", this); | ||
final String path = "/{index}/_eql/search"; |
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.
Could you make a constant out of this?
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.
done
for (int i = 0; i < size; i++) { | ||
arr.add(randomAlphaOfLength(randomIntBetween(1, 15))); | ||
private SearchAfterBuilder randomJsonSearchFromBuilder() throws IOException { | ||
int numSearchAfter = randomIntBetween(1, 10); |
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.
How about an empty list?
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.
normally SearchAfter doesn't accept the empty list, throws error:
java.lang.IllegalArgumentException: Values must contains at least one value.
The original searchafter test doesn't use empty list as well
elasticsearch/server/src/test/java/org/elasticsearch/search/searchafter/SearchAfterBuilderTests.java
Line 101 in df83eb9
int numSearchAfter = randomIntBetween(1, 10); |
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.
How about returning setting search after values to null sometimes then?
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.
Already handled there as well
java.lang.NullPointerException: Values cannot be null.
at __randomizedtesting.SeedInfo.seed([1C63F70E75AEE77B:48BB964652FCDAE7]:0)
at org.elasticsearch.search.searchafter.SearchAfterBuilder.setSortValues(SearchAfterBuilder.java:78)
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.
discussed over slack, updated implementation
jsonBuilder.startObject(); | ||
jsonBuilder.startArray("search_after"); | ||
for (int i = 0; i < numSearchAfter; i++) { | ||
int branch = randomInt(9); |
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 think there is LuceneTests.randomSortValue()
that generates random sort values. I wonder if we could use it here.
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 it is not possible, I think there is a better pattern for this base on randomFrom(...)
and Supplier<...>
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.
updated to a better pattern
1717177
to
68ee15f
Compare
68ee15f
to
1bd4327
Compare
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. Thanks!
Correct the initial "naive" handling of search_after parameters.