Documentation updates for scroll API size parameter (#21229)
* Document size parameter for scroll API * Fix size parameter behavior description for scroll
This commit is contained in:
parent
8dd91eb2d6
commit
1f1daf59bc
|
@ -58,7 +58,7 @@ SearchResponse scrollResp = client.prepareSearch(test)
|
|||
.addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC)
|
||||
.setScroll(new TimeValue(60000))
|
||||
.setQuery(qb)
|
||||
.setSize(100).execute().actionGet(); //100 hits per shard will be returned for each scroll
|
||||
.setSize(100).execute().actionGet(); //max of 100 hits will be returned for each scroll
|
||||
//Scroll until no hits are returned
|
||||
do {
|
||||
for (SearchHit hit : scrollResp.getHits().getHits()) {
|
||||
|
@ -68,10 +68,6 @@ do {
|
|||
scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(60000)).execute().actionGet();
|
||||
} while(scrollResp.getHits().getHits().length != 0); // Zero hits mark the end of the scroll and the while loop.
|
||||
--------------------------------------------------
|
||||
[NOTE]
|
||||
====
|
||||
The size-parameter is per shard, so if you run a query against multiple indices (leading to many shards being involved in the query) the result might be more documents per execution of the scroll than you would expect!
|
||||
====
|
||||
|
||||
[[java-search-msearch]]
|
||||
=== MultiSearch API
|
||||
|
|
|
@ -40,6 +40,7 @@ should keep the ``search context'' alive (see <<scroll-search-context>>), eg `?s
|
|||
--------------------------------------------------
|
||||
POST /twitter/tweet/_search?scroll=1m
|
||||
{
|
||||
"size": 100,
|
||||
"query": {
|
||||
"match" : {
|
||||
"title" : "elasticsearch"
|
||||
|
@ -72,8 +73,10 @@ POST <1> /_search/scroll <2>
|
|||
for another `1m`.
|
||||
<4> The `scroll_id` parameter
|
||||
|
||||
Each call to the `scroll` API returns the next batch of results until there
|
||||
are no more results left to return, ie the `hits` array is empty.
|
||||
The `size` parameter allows you to configure the maximum number of hits to be
|
||||
returned with each batch of results. Each call to the `scroll` API returns the
|
||||
next batch of results until there are no more results left to return, ie the
|
||||
`hits` array is empty.
|
||||
|
||||
IMPORTANT: The initial search request and each subsequent scroll request
|
||||
returns a new `_scroll_id` -- only the most recent `_scroll_id` should be
|
||||
|
|
Loading…
Reference in New Issue