GET /_search?size=5
GET /_search?size=5&from=5
GET /_search?size=5&from=10
Pagination
Our preceding empty search told us that 14 documents in the
cluster match our (empty) query. But there were only 10 documents in
the hits
array. How can we see the other documents?
In the same way as SQL uses the LIMIT
keyword to return a single `page'' of
results, Elasticsearch accepts the `from
and size
parameters:
size
-
Indicates the number of results that should be returned, defaults to
10
from
-
Indicates the number of initial results that should be skipped, defaults to
0
If you wanted to show five results per page, then pages 1 to 3 could be requested as follows:
Beware of paging too deep or requesting too many results at once. Results are sorted before being returned. But remember that a search request usually spans multiple shards. Each shard generates its own sorted results, which then need to be sorted centrally to ensure that the overall order is correct.
Tip
|
In [reindex] we explain how you can retrieve large numbers of documents efficiently. |