Run a scrolling search
IMPORTANT: The scroll API is no longer recommend 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).
The scroll API gets large sets of results from a single scrolling search request.
To get the necessary 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.
IMPORTANT: 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.
Query parameters
-
scroll string
Period to retain the search context for scrolling.
-
The scroll ID for scrolled search
-
rest_total_hits_as_int boolean
If true, the API response’s hit.total property is returned as an integer. If false, the API response’s hit.total property is returned as an object.
curl \
-X POST http://api.example.com/_search/scroll \
-H "Content-Type: application/json" \
-d '{"scroll":"string","scroll_id":"string"}'
{
"scroll": "string",
"scroll_id": "string"
}
{
"took": 42.0,
"timed_out": true,
"_shards": {
"failed": 42.0,
"successful": 42.0,
"total": 42.0,
"failures": [
{
"index": "string",
"node": "string",
"reason": {
"type": "string",
"reason": "string",
"stack_trace": "string",
"caused_by": {},
"root_cause": [
{}
],
"suppressed": [
{}
]
},
"shard": 42.0,
"status": "string"
}
],
"skipped": 42.0
},
"hits": {
"total": {
"relation": "eq",
"value": 42.0
},
"hits": [
{
"_index": "string",
"_id": "string",
"_score": 42.0,
"_explanation": {
"description": "string",
"details": [
{}
],
"value": 42.0
},
"fields": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"highlight": {
"additionalProperty1": [
"string"
],
"additionalProperty2": [
"string"
]
},
"inner_hits": {
"additionalProperty1": {
"hits": {}
},
"additionalProperty2": {
"hits": {}
}
},
"matched_queries": [
"string"
],
"_nested": {
"field": "string",
"offset": 42.0,
"_nested": {}
},
"_ignored": [
"string"
],
"ignored_field_values": {
"additionalProperty1": [
{}
],
"additionalProperty2": [
{}
]
},
"_shard": "string",
"_node": "string",
"_routing": "string",
"_source": {},
"_rank": 42.0,
"_seq_no": 42.0,
"_primary_term": 42.0,
"_version": 42.0,
"sort": [
42.0
]
}
],
"max_score": 42.0
},
"aggregations": {},
"_clusters": {
"skipped": 42.0,
"successful": 42.0,
"total": 42.0,
"running": 42.0,
"partial": 42.0,
"failed": 42.0,
"details": {
"additionalProperty1": {
"status": "running",
"indices": "string",
"": 42.0,
"timed_out": true,
"_shards": {
"failed": 42.0,
"successful": 42.0,
"total": 42.0,
"failures": [
{}
],
"skipped": 42.0
},
"failures": [
{
"index": "string",
"node": "string",
"reason": {},
"shard": 42.0,
"status": "string"
}
]
},
"additionalProperty2": {
"status": "running",
"indices": "string",
"": 42.0,
"timed_out": true,
"_shards": {
"failed": 42.0,
"successful": 42.0,
"total": 42.0,
"failures": [
{}
],
"skipped": 42.0
},
"failures": [
{
"index": "string",
"node": "string",
"reason": {},
"shard": 42.0,
"status": "string"
}
]
}
}
},
"fields": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"max_score": 42.0,
"num_reduce_phases": 42.0,
"profile": {
"shards": [
{
"aggregations": [
{
"breakdown": {},
"description": "string",
"type": "string",
"debug": {},
"children": [
{}
]
}
],
"cluster": "string",
"dfs": {
"statistics": {
"type": "string",
"description": "string",
"time": "string",
"breakdown": {},
"debug": {},
"children": [
{}
]
},
"knn": [
{}
]
},
"fetch": {
"type": "string",
"description": "string",
"": 42.0,
"breakdown": {
"load_source": 42.0,
"load_source_count": 42.0,
"load_stored_fields": 42.0,
"load_stored_fields_count": 42.0,
"next_reader": 42.0,
"next_reader_count": 42.0,
"process_count": 42.0,
"process": 42.0
},
"debug": {
"stored_fields": [
"string"
],
"fast_path": 42.0
},
"children": [
{}
]
},
"id": "string",
"index": "string",
"node_id": "string",
"searches": [
{
"collector": [
{}
],
"query": [
{}
],
"rewrite_time": 42.0
}
],
"shard_id": 42.0
}
]
},
"pit_id": "string",
"_scroll_id": "string",
"suggest": {
"additionalProperty1": [
{
"length": 42.0,
"offset": 42.0,
"text": "string"
}
],
"additionalProperty2": [
{
"length": 42.0,
"offset": 42.0,
"text": "string"
}
]
},
"terminated_early": true
}