mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 01:19:02 +00:00
Update the scroll example in the docs (#37394)
Update the scroll example ascii and Java docs, so it is more clear when to consume the scroll documents. Before this change the user could loose the first results if one uses copy & paste.
This commit is contained in:
parent
4b1368183d
commit
87f9148580
@ -715,12 +715,12 @@ public class SearchDocumentationIT extends ESRestHighLevelClientTestCase {
|
||||
SearchHit[] searchHits = searchResponse.getHits().getHits();
|
||||
|
||||
while (searchHits != null && searchHits.length > 0) { // <2>
|
||||
SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); // <3>
|
||||
// <3>
|
||||
SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); // <4>
|
||||
scrollRequest.scroll(scroll);
|
||||
searchResponse = client.scroll(scrollRequest, RequestOptions.DEFAULT);
|
||||
scrollId = searchResponse.getScrollId();
|
||||
searchHits = searchResponse.getHits().getHits();
|
||||
// <4>
|
||||
}
|
||||
|
||||
ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); // <5>
|
||||
|
@ -128,9 +128,9 @@ include-tagged::{doc-tests}/SearchDocumentationIT.java[search-scroll-example]
|
||||
<1> Initialize the search context by sending the initial `SearchRequest`
|
||||
<2> Retrieve all the search hits by calling the Search Scroll api in a loop
|
||||
until no documents are returned
|
||||
<3> Create a new `SearchScrollRequest` holding the last returned scroll
|
||||
<3> Process the returned search results
|
||||
<4> Create a new `SearchScrollRequest` holding the last returned scroll
|
||||
identifier and the scroll interval
|
||||
<4> Process the returned search results
|
||||
<5> Clear the scroll context once the scroll is completed
|
||||
|
||||
[[java-rest-high-clear-scroll]]
|
||||
|
Loading…
x
Reference in New Issue
Block a user