-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Docs] Document Scroll API for Java High Level REST Client #25554
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,37 +29,30 @@ include-tagged::{doc-tests}/SearchDocumentationIT.java[search-response-scroll-id | |
| <2> Retrieve the search hits | ||
| <3> Retrieve the scroll id | ||
|
|
||
| This scroll id should be passed to a `SearchScrollRequest`: | ||
| This scroll id should be passed to a `SearchScrollRequest` which can be executed | ||
| using the Search Scroll API in order to retrieve the next batch of results. Then | ||
| the same process can be repeated over and over until no more results are returned. | ||
| The initial search request as well as all subsequent scroll requests return a | ||
| scroll id that can be passed to the next scroll request until results are exhausted. | ||
|
|
||
| ["source","java",subs="attributes,callouts,macros"] | ||
| -------------------------------------------------- | ||
| include-tagged::{doc-tests}/SearchDocumentationIT.java[search-scroll-id] | ||
| include-tagged::{doc-tests}/SearchDocumentationIT.java[search-scroll-execute] | ||
| -------------------------------------------------- | ||
| <1> Create a new `SearchScrollRequest` | ||
| <2> Set the `scroll` parameter again to tell Elasticsearch to keep the search context | ||
| alive for another minute | ||
| <3> Set the scroll id | ||
|
|
||
| And the `SearchScrollRequest` can be executed using the Search Scroll API in order | ||
| to retrieve the next batch of results: | ||
|
|
||
| ["source","java",subs="attributes,callouts,macros"] | ||
| -------------------------------------------------- | ||
| include-tagged::{doc-tests}/SearchDocumentationIT.java[search-scroll-execute] | ||
| -------------------------------------------------- | ||
| <1> Execute the `SearchScrollRequest` | ||
| <2> Retrieve the next batch of search hits | ||
| <3> Retrieve the next scroll id to use in upcoming requests | ||
|
|
||
| Then the same process can be repeated over and over until no more results are | ||
| returned. The initial search request as well as all subsequent scroll requests | ||
| return a scroll id that can be passed to the next scroll request until results | ||
| are exhausted. | ||
| <4> Execute the `SearchScrollRequest` | ||
| <5> Retrieve the next scroll id to use in upcoming requests | ||
| <6> Retrieve the next batch of search hits | ||
| <7> The request returned search hits that can be processed | ||
| <8> There are no more search hits to process, the scrolling is terminated | ||
|
|
||
| Finally, the scroll id can be deleted using the <<java-rest-high-clear-scroll>>. | ||
|
|
||
| ==== Optional arguments | ||
| The following arguments can optionally be provided: | ||
| The following argument can optionally be provided: | ||
|
|
||
| ["source","java",subs="attributes,callouts,macros"] | ||
| -------------------------------------------------- | ||
|
|
@@ -68,6 +61,10 @@ include-tagged::{doc-tests}/SearchDocumentationIT.java[scroll-request-scroll] | |
| <1> Scroll value (ie, the time to keep alive the search context) as a `TimeValue` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't realize that the scroll was optional. Maybe we should mention the default value when not specified? |
||
| <2> Scroll value (ie, the time to keep alive the search context) as a `String` | ||
|
|
||
| If no `scroll` value is set for the `SearchScrollRequest`, then the search context | ||
| will expire once the initial scroll time expired (ie, the scroll time set in the | ||
| initial search request). | ||
|
|
||
| [[java-rest-high-search-scroll-sync]] | ||
| ==== Synchronous Execution | ||
|
|
||
|
|
@@ -93,7 +90,7 @@ provided as an argument | |
|
|
||
| The search contexts used by the Scroll API are automatically deleted when the scroll | ||
| times out. But it is advised to release search contexts as soon as they are not | ||
| necessary anymore using the Clear Scroll API: | ||
| necessary anymore using the Clear Scroll API. | ||
|
|
||
| [[java-rest-high-clear-scroll-request]] | ||
| ==== Clear Scroll Request | ||
|
|
@@ -110,7 +107,7 @@ include-tagged::{doc-tests}/SearchDocumentationIT.java[clear-scroll-request] | |
| ==== Providing the scroll identifiers | ||
| The `ClearScrollRequest` allows to clear one or more scroll identifiers in a single request. | ||
|
|
||
| The scroll identifier can be added to the request one by one: | ||
| The scroll identifiers can be added to the request one by one: | ||
|
|
||
| ["source","java",subs="attributes,callouts,macros"] | ||
| -------------------------------------------------- | ||
|
|
@@ -153,5 +150,5 @@ The returned `ClearScrollResponse` allows to retrieve information about the rele | |
| -------------------------------------------------- | ||
| include-tagged::{doc-tests}/SearchDocumentationIT.java[clear-scroll-response] | ||
| -------------------------------------------------- | ||
| <1> Return true if the request succeed | ||
| <1> Return true if the request succeeded | ||
| <2> Return the number of released search contexts | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 having a complete example with the initial search response too? Maybe leave a separate search scroll snippet, then move to the complete example where you reuse the SearchHits from the initial SearchResponse and you could do while(searchHits != null && searchHits.length > 0) instead of while(true)? Would that work or would it be too complicated?
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.
Ok, I updated the doc in 0c2d815, let me know if this is OK or not.
I'm personally fine with the latest version as well as the previous one too, just let me know which one seems better to you.