Skip to content

Commit

Permalink
Update the scroll example in the docs (#37394)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
j0r0 authored and Christoph Büscher committed Jan 14, 2019
1 parent 4b13681 commit 87f9148
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -715,12 +715,12 @@ public void onFailure(Exception e) {
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>
Expand Down
4 changes: 2 additions & 2 deletions docs/java-rest/high-level/search/scroll.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down

0 comments on commit 87f9148

Please sign in to comment.