Browse Source

Docs: Some Data Cant't be obtained.

In previous case, the first 100 data can't be obtained.

Closes #8103
wmx3ng 11 years ago
parent
commit
940534299d
1 changed files with 2 additions and 1 deletions
  1. 2 1
      docs/java-api/search.asciidoc

+ 2 - 1
docs/java-api/search.asciidoc

@@ -62,10 +62,11 @@ SearchResponse scrollResp = client.prepareSearch(test)
         .setSize(100).execute().actionGet(); //100 hits per shard will be returned for each scroll
 //Scroll until no hits are returned
 while (true) {
-    scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
+
     for (SearchHit hit : scrollResp.getHits()) {
         //Handle the hit...
     }
+    scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
     //Break condition: No hits are returned
     if (scrollResp.getHits().getHits().length == 0) {
         break;