Scroll API
We no longer recommend using the scroll API for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the search_after parameter with a point in time (PIT).
Retrieves the next batch of results for a scrolling search.
GET /_search/scroll
{
"scroll_id" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ=="
} Request
GET /_search/scroll/<scroll_id> [7.0.0] Deprecated in 7.0.0.
GET /_search/scroll
POST /_search/scroll/<scroll_id> [7.0.0] Deprecated in 7.0.0.
POST /_search/scroll
Prerequisites
- If the Elasticsearch security features are enabled, you must have the
readindex privilege for the target data stream, index, or alias.
Description
You can use the scroll API to retrieve large sets of results from a single scrolling search request.
The scroll API requires a scroll ID. To get a scroll ID, submit a search API request that includes an argument for the scroll query parameter. The scroll parameter indicates how long Elasticsearch should retain the search context for the request.
The search response returns a scroll ID in the _scroll_id response body parameter. You can then use the scroll ID with the scroll API to retrieve the next batch of results for the request. If the Elasticsearch security features are enabled, the access to the results of a specific scroll ID is restricted to the user or API key that submitted the search.
You can also use the scroll API to specify a new scroll parameter that extends or shortens the retention period for the search context.
Results from a scrolling search reflect the state of the index at the time of the initial search request. Subsequent indexing or document changes only affect later search and scroll requests.
Path parameters
-
<scroll_id> -
[7.0.0] Deprecated in 7.0.0. (Optional, string) Scroll ID of the search.
Scroll IDs can be long. We recommend only specifying scroll IDs using the
scroll_idrequest body parameter.
Query parameters
-
scroll -
(Optional, time value) Period to retain the search context for scrolling. See Scroll search results.
This value overrides the duration set by the original search API request’s
scrollparameter.By default, this value cannot exceed
1d(24 hours). You can change this limit using thesearch.max_keep_alivecluster-level setting.You can also specify this value using the
scrollrequest body parameter. If both parameters are specified, only the query parameter is used. -
scroll_id -
[7.0.0] Deprecated in 7.0.0. (Optional, string) Scroll ID for the search.
Scroll IDs can be long. We recommend only specifying scroll IDs using the
scroll_idrequest body parameter. -
rest_total_hits_as_int - (Optional, Boolean) If
true, the API response’shit.totalproperty is returned as an integer. Iffalse, the API response’shit.totalproperty is returned as an object. Defaults tofalse.
Request body
-
scroll -
(Optional, time value) Period to retain the search context for scrolling. See Scroll search results.
This value overrides the duration set by the original search API request’s
scrollparameter.By default, this value cannot exceed
1d(24 hours). You can change this limit using thesearch.max_keep_alivecluster-level setting.You can also specify this value using the
scrollquery parameter. If both parameters are specified, only the query parameter is used.
-
scroll_id - (Required, string) Scroll ID for the search.
Response body
The scroll API returns the same response body as the search API. See the search API’s response body parameters.
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/scroll-api.html