You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/7/core-classes/search-result/next/index.md
+11-4Lines changed: 11 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,9 @@ next();
20
20
21
21
Resolves to a `SearchResult` object, or to `null` if no more pages are available.
22
22
23
-
## Throw
23
+
## Rejects
24
24
25
-
This method throws an exception if:
25
+
This method returns a rejected promise with an error if:
26
26
27
27
- No pagination strategy can be applied (see below)
28
28
- If invoking it would lead to more than 10 000 items being retrieved with the `from/size` strategy
@@ -56,19 +56,26 @@ You can restrict the scroll session maximum duration under the `services.storage
56
56
57
57
If the initial search contains `sort` and `size` parameters, the `next` method retrieves the next page of results following the sort order, the last item of the current page acting as a live cursor.
58
58
59
-
To avoid too many duplicates, it is advised to provide a sort combination that will always identify one item only. The recommended way is to use the field `_uid` which is certain to contain one unique value for each document.
59
+
This strategy uses Elasticsearch [search_after](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-request-body.html#request-body-search-search-after) parameter.
60
+
61
+
::: warning
62
+
You have to provide a sort combination that will always identify one item only. The recommended way is to use the field `_id` which is certain to contain one unique value for each document.
63
+
To prevent partial retrieval of results, the SDK will reject with an error if the sort combination can identify multiple items.
64
+
:::
60
65
61
66
Because this method does not freeze the search results between two calls, there can be missing or duplicated documents between two result pages.
62
67
63
68
This method efficiently mitigates the costs of scroll searches, but returns less consistent results: it's a middle ground, ideal for real-time search requests.
64
69
70
+
<<< ./snippets/sortsize.js
71
+
65
72
### Strategy: from / size
66
73
67
74
If the initial search contains `from` and `size` parameters, the `next` method retrieves the next page of result by incrementing the `from` offset.
68
75
69
76
Because this method does not freeze the search results between two calls, there can be missing or duplicated documents between two result pages.
70
77
71
78
It's the fastest pagination method available, but also the less consistent, and it is not possible to retrieve more than 10000 items using it.
72
-
Above that limit, any call to `next`throws an Exception.
79
+
Above that limit, any call to `next`will return a rejected promise with an error.
"[Expo](https://docs.expo.io/versions/latest/) is a framework and a platform for universal React applications. It is a set of tools and services built around React Native and native platforms that help you develop, build, deploy, and quickly iterate on iOS, Android, and web apps from the same JavaScript/TypeScript codebase."
0 commit comments