Run a scrolling search

  • POST also GET /_search/scroll/{scroll_id}
  • POST also GET /_search/scroll
Auth
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.

About paginating search results

Required privileges

Index privileges read

Path parameters

scroll_id string optional deprecated

The scroll ID

Leave it out to use /_search/scroll.

Query parameters

scroll union oneOf · default: 1d

The period to retain the search context for scrolling.

Values: -1 0
scroll_id string deprecated

The scroll ID

rest_total_hits_as_int boolean · default: false

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.

Request body

scroll union oneOf · default: 1d

The period to retain the search context for scrolling.

Values: -1 0
scroll_id string required

The scroll ID of the search.

Response

application/json
took number required

The number of milliseconds it took Elasticsearch to run the request. This value is calculated by measuring the time elapsed between receipt of a request on the coordinating node and the time at which the coordinating node is ready to send the response. It includes:

  • Communication time between the coordinating node and data nodes
  • Time the request spends in the search thread pool, queued for execution
  • Actual run time

It does not include:

  • Time needed to send the request to Elasticsearch
  • Time needed to serialize the JSON response
  • Time needed to send the response to a client
timed_out boolean required

If true, the request timed out before completion; returned results may be partial or empty.

_shards object required

A count of shards used for the request.

failed number required

The number of shards the operation or search attempted to run on but failed.

successful number required

The number of shards the operation or search succeeded on.

total number required

The number of shards the operation or search will run on overall.

skipped number
hits object required

The returned documents and metadata.

total union oneOf

Total hit count information, present only if track_total_hits wasn't false in the search request.

One of:
relation enum required

Supported values include:

  • eq: Accurate
  • gte: Lower bound, including returned events or sequences
Values: eq gte
value number required
hits object[] required
_index string required
_id string
_score union number | string nullable
fields map string to object
highlight map string to string
inner_hits map string to object
matched_queries union oneOf
One of: string[] or string to number
_ignored string[]
ignored_field_values map string to object
_shard string
_node string
_routing string
_source object
_rank number
_seq_no number
_primary_term number
_version number
sort union[]
max_score union number | string nullable
aggregations map string to {} Aggregation result
fields map string to object
max_score number
num_reduce_phases number
pit_id string

An updated identifier for the point-in-time that was searched.

Important

Each search request against a PIT returns in its response a pit_id field which may be different from the identifier you originally supplied. Always use the most recently-received PIT identifier for the next request. If you make concurrent search requests against the same PIT, Elasticsearch can return several different pit_id values in its responses. In that case, use any of these values for later requests, preferring more recently-received values whenever possible.

_scroll_id string

The identifier for the search and its search context. You can use this scroll ID with the scroll API to retrieve the next batch of search results for the request. This property is returned only if the scroll query parameter is specified in the request.

suggest map string to oneOf
terminated_early boolean