-
Notifications
You must be signed in to change notification settings - Fork 208
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
Implement basic search with point in time and search after #2847
Implement basic search with point in time and search after #2847
Conversation
67f1df6
to
becb43d
Compare
Signed-off-by: Taylor Gray <[email protected]>
becb43d
to
a858cee
Compare
|
||
import java.util.List; | ||
|
||
public class SearchPointInTimeResponse { |
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'd perhaps rename this. At first glance it looks like it is intended to be similar to the opensearch-java APIs. But, it is quite different.
Perhaps: SearchPointInTimeResults
or SearchPointInTimeOutput
?
|
||
return SearchPointInTimeResponse.builder() | ||
.withDocuments(documents) | ||
.withNextSearchAfter(searchResponse.hits().hits().get(searchResponse.hits().hits().size() - 1).sort()) |
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'm not sure I follow how you get the next search after. Is there no order from the OpenSearch response that could help here?
Also, you have an inline sort()
. That should probably be pulled out of this line as it is somewhat signficiant.
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 see, this is the OpenSearch "sort" model, not a collection sort.
|
||
return SearchPointInTimeResponse.builder() | ||
.withDocuments(documents) | ||
.withNextSearchAfter(searchResponse.hits().hits().get(searchResponse.hits().hits().size() - 1).sort()) |
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.
Can the size be 0
? What if your paging results in a final empty page?
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 it can be good catch.
@@ -20,10 +20,10 @@ public class SearchConfiguration { | |||
private static final Logger LOG = LoggerFactory.getLogger(SearchConfiguration.class); | |||
|
|||
@JsonProperty("batch_size") | |||
private Integer batchSize; | |||
private Integer batchSize = 1000; |
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.
nit
DEFAULT_BATCH_SIZE=1000
Signed-off-by: Taylor Gray <[email protected]>
I'd also recommend that you rename |
…h-project#2847) Implement basic search with point in time and search after Signed-off-by: Taylor Gray <[email protected]> Signed-off-by: Marcos_Gonzalez_Mayedo <[email protected]>
Description
Implements searching via point in time. Paginates based on the
batch_size
in the opensearch config (defaults to 1000)Limitations of this PR:
query
passed in the config is currently unused, as the opensearch java client does not support passing query strings or query maps directly to search requests ([FEATURE] Send search request query DSL json directly to search request opensearch-java#525). For now, only processing all documents via amatch_all
query and default sorting in ascending mode is supported.Issues Resolved
Related to #1985
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.