From 6cd90e19ea665724479c4bd88d5770d403d56356 Mon Sep 17 00:00:00 2001 From: Kofi Bartlett Date: Fri, 28 Feb 2025 11:07:24 +0900 Subject: [PATCH 1/2] This is a copy from the original ticket https://github.com/elastic/elasticsearch/pull/120171 --- .../paginate-search-results.asciidoc | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/reference/search/search-your-data/paginate-search-results.asciidoc b/docs/reference/search/search-your-data/paginate-search-results.asciidoc index f69fd60be0484..bcb26d4a69ffd 100644 --- a/docs/reference/search/search-your-data/paginate-search-results.asciidoc +++ b/docs/reference/search/search-your-data/paginate-search-results.asciidoc @@ -1,6 +1,18 @@ [[paginate-search-results]] === Paginate search results +Pagination organizes search results into manageable pages, enhancing user interaction. Whether selecting specific page ranges or using infinite scroll, pagination offers a tailored user experience. + +The three commonly used pagination techniques are: + +* <>: Ideal for creating a list of pages that users can navigate. +* <>: Supports infinite scroll or allows loading additional results with a "next" button. +* <>: Historically used to retrieve all matching documents. The <> method with the <> is now recommended for better efficiency and reliability. + +[discrete] +[[from-and-size-pagination]] +=== From and size pagination + By default, searches return the top 10 matching hits. To page through a larger set of results, you can use the <>'s `from` and `size` parameters. The `from` parameter defines the number of hits to skip, defaulting @@ -25,7 +37,7 @@ Avoid using `from` and `size` to page too deeply or request too many results at once. Search requests usually span multiple shards. Each shard must load its requested hits and the hits for any previous pages into memory. For deep pages or large sets of results, these operations can significantly increase memory and -CPU usage, resulting in degraded performance or node failures. +CPU usage. If not properly managed, these operations can result in degraded performance or node failures. By default, you cannot use `from` and `size` to page through more than 10,000 hits. This limit is a safeguard set by the @@ -33,6 +45,8 @@ hits. This limit is a safeguard set by the to page through more than 10,000 hits, use the <> parameter instead. +Pagination is stateless, so search result order may change when navigating between pages. To maintain consistent order, use the <> for stateful pagination. + WARNING: {es} uses Lucene's internal doc IDs as tie-breakers. These internal doc IDs can be completely different across replicas of the same data. When paging search hits, you might occasionally see that documents with the same sort values @@ -43,7 +57,7 @@ are not ordered consistently. === Search after You can use the `search_after` parameter to retrieve the next page of hits -using a set of <> from the previous page. +using a set of <> 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. Using `search_after` requires multiple search requests with the same `query` and `sort` values. The first step is to run an initial request. The following @@ -629,4 +643,4 @@ GET /my-index-000001/_search?scroll=1m -------------------------------------------------- // TEST[setup:my_index_big] -For append only time-based indices, the `timestamp` field can be used safely. +For append only time-based indices, the `timestamp` field can be used safely. \ No newline at end of file From 40deca3e3c99c7f2c78c840a45a53d1a991d0564 Mon Sep 17 00:00:00 2001 From: George Wallace Date: Fri, 28 Feb 2025 13:14:12 -0700 Subject: [PATCH 2/2] Update docs/reference/search/search-your-data/paginate-search-results.asciidoc Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com> --- .../search/search-your-data/paginate-search-results.asciidoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/reference/search/search-your-data/paginate-search-results.asciidoc b/docs/reference/search/search-your-data/paginate-search-results.asciidoc index bcb26d4a69ffd..ffb79bf9cb595 100644 --- a/docs/reference/search/search-your-data/paginate-search-results.asciidoc +++ b/docs/reference/search/search-your-data/paginate-search-results.asciidoc @@ -1,9 +1,10 @@ [[paginate-search-results]] === Paginate search results -Pagination organizes search results into manageable pages, enhancing user interaction. Whether selecting specific page ranges or using infinite scroll, pagination offers a tailored user experience. +{es} uses pagination to segment large result sets into manageable pages for efficient retrieval and processing. + +{es} supports three pagination techniques: -The three commonly used pagination techniques are: * <>: Ideal for creating a list of pages that users can navigate. * <>: Supports infinite scroll or allows loading additional results with a "next" button.