From 87f91485805d0f3eb54dd6eacaac5994f6faa090 Mon Sep 17 00:00:00 2001 From: Georgi Ivanov Date: Mon, 14 Jan 2019 13:03:00 +0100 Subject: [PATCH] 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. --- .../client/documentation/SearchDocumentationIT.java | 4 ++-- docs/java-rest/high-level/search/scroll.asciidoc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java index dc85e85e9b29d..3a49a13479e87 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java @@ -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> diff --git a/docs/java-rest/high-level/search/scroll.asciidoc b/docs/java-rest/high-level/search/scroll.asciidoc index 8a6d9830f88d6..8285243103abe 100644 --- a/docs/java-rest/high-level/search/scroll.asciidoc +++ b/docs/java-rest/high-level/search/scroll.asciidoc @@ -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]]