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:
Georgi Ivanov 2019-01-14 13:03:00 +01:00 committed by Christoph Büscher
parent 4b1368183d
commit 87f9148580
2 changed files with 4 additions and 4 deletions

View File

@ -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>

View File

@ -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]]