Skip to content

Commit 9b100c2

Browse files
georgewallacethekofimensahleemthompo
authored
Opster paginate changes rebase (elastic#123674) (elastic#123787)
* This is a copy from the original ticket elastic#120171 * Update docs/reference/search/search-your-data/paginate-search-results.asciidoc --------- Co-authored-by: Kofi B <[email protected]> Co-authored-by: Liam Thompson <[email protected]>
1 parent f07cc80 commit 9b100c2

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

docs/reference/search/search-your-data/paginate-search-results.asciidoc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
[[paginate-search-results]]
22
=== Paginate search results
33

4+
{es} uses pagination to segment large result sets into manageable pages for efficient retrieval and processing.
5+
6+
{es} supports three pagination techniques:
7+
8+
9+
* <<from-and-size-pagination, From and size pagination>>: Ideal for creating a list of pages that users can navigate.
10+
* <<search-after, Search after>>: Supports infinite scroll or allows loading additional results with a "next" button.
11+
* <<scroll-search-results, Scroll>>: Historically used to retrieve all matching documents. The <<search-after, search after>> method with the <<point-in-time-api, point in time API>> is now recommended for better efficiency and reliability.
12+
13+
[discrete]
14+
[[from-and-size-pagination]]
15+
=== From and size pagination
16+
417
By default, searches return the top 10 matching hits. To page through a larger
518
set of results, you can use the <<search-search,search API>>'s `from` and `size`
619
parameters. The `from` parameter defines the number of hits to skip, defaulting
@@ -25,14 +38,16 @@ Avoid using `from` and `size` to page too deeply or request too many results at
2538
once. Search requests usually span multiple shards. Each shard must load its
2639
requested hits and the hits for any previous pages into memory. For deep pages
2740
or large sets of results, these operations can significantly increase memory and
28-
CPU usage, resulting in degraded performance or node failures.
41+
CPU usage. If not properly managed, these operations can result in degraded performance or node failures.
2942

3043
By default, you cannot use `from` and `size` to page through more than 10,000
3144
hits. This limit is a safeguard set by the
3245
<<index-max-result-window,`index.max_result_window`>> index setting. If you need
3346
to page through more than 10,000 hits, use the <<search-after,`search_after`>>
3447
parameter instead.
3548

49+
Pagination is stateless, so search result order may change when navigating between pages. To maintain consistent order, use the <<point-in-time-api, point in time API>> for stateful pagination.
50+
3651
WARNING: {es} uses Lucene's internal doc IDs as tie-breakers. These internal doc
3752
IDs can be completely different across replicas of the same data. When paging
3853
search hits, you might occasionally see that documents with the same sort values
@@ -43,7 +58,7 @@ are not ordered consistently.
4358
=== Search after
4459

4560
You can use the `search_after` parameter to retrieve the next page of hits
46-
using a set of <<sort-search-results,sort values>> from the previous page.
61+
using a set of <<sort-search-results,sort values>> from the previous page. This approach is ideal for scenarios where users click a "next" or "load more" button, rather than selecting a specific page.
4762

4863
Using `search_after` requires multiple search requests with the same `query` and
4964
`sort` values. The first step is to run an initial request. The following
@@ -629,4 +644,4 @@ GET /my-index-000001/_search?scroll=1m
629644
--------------------------------------------------
630645
// TEST[setup:my_index_big]
631646

632-
For append only time-based indices, the `timestamp` field can be used safely.
647+
For append only time-based indices, the `timestamp` field can be used safely.

0 commit comments

Comments
 (0)