Skip to content

Commit f2c9051

Browse files
j0r0Christoph Büscher
authored andcommitted
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.
1 parent 9b5f9cc commit f2c9051

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,12 @@ public void onFailure(Exception e) {
709709
SearchHit[] searchHits = searchResponse.getHits().getHits();
710710

711711
while (searchHits != null && searchHits.length > 0) { // <2>
712-
SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); // <3>
712+
// <3>
713+
SearchScrollRequest scrollRequest = new SearchScrollRequest(scrollId); // <4>
713714
scrollRequest.scroll(scroll);
714715
searchResponse = client.scroll(scrollRequest, RequestOptions.DEFAULT);
715716
scrollId = searchResponse.getScrollId();
716717
searchHits = searchResponse.getHits().getHits();
717-
// <4>
718718
}
719719

720720
ClearScrollRequest clearScrollRequest = new ClearScrollRequest(); // <5>

docs/java-rest/high-level/search/scroll.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ include-tagged::{doc-tests}/SearchDocumentationIT.java[search-scroll-example]
128128
<1> Initialize the search context by sending the initial `SearchRequest`
129129
<2> Retrieve all the search hits by calling the Search Scroll api in a loop
130130
until no documents are returned
131-
<3> Create a new `SearchScrollRequest` holding the last returned scroll
131+
<3> Process the returned search results
132+
<4> Create a new `SearchScrollRequest` holding the last returned scroll
132133
identifier and the scroll interval
133-
<4> Process the returned search results
134134
<5> Clear the scroll context once the scroll is completed
135135

136136
[[java-rest-high-clear-scroll]]

0 commit comments

Comments
 (0)