Skip to content

Commit 24a46eb

Browse files
Merge branch 'v0.28-pagination-settings' into update-indexes.md-to-add-pagination
2 parents 3d3d3de + f48fe20 commit 24a46eb

File tree

7 files changed

+168
-43
lines changed

7 files changed

+168
-43
lines changed

.code-samples.meilisearch.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ update_settings_1: |-
183183
"twoTypos": 10
184184
},
185185
"disableOnAttributes": ["title"]
186+
},
187+
"pagination": {
188+
"maxTotalHits": 5000
186189
}
187190
}'
188191
reset_settings_1: |-
@@ -964,4 +967,17 @@ settings_guide_pagination_1: |-
964967
-H 'Content-Type: application/json' \
965968
--data-binary '{
966969
"maxTotalHits": 50
967-
}'
970+
}'
971+
get_pagination_settings_1: |-
972+
curl \
973+
-X GET 'http://localhost:7700/indexes/books/settings/pagination'
974+
update_pagination_settings_1: |-
975+
curl \
976+
-X PATCH 'http://localhost:7700/indexes/books/settings/pagination' \
977+
-H 'Content-Type: application/json' \
978+
--data-binary '{
979+
"maxTotalHits": 100
980+
}'
981+
reset_pagination_settings_1: |-
982+
curl \
983+
-X DELETE 'http://localhost:7700/indexes/books/settings/pagination'

.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ module.exports = {
324324
'/reference/api/displayed_attributes',
325325
'/reference/api/distinct_attribute',
326326
'/reference/api/filterable_attributes',
327+
'/reference/api/pagination',
327328
'/reference/api/ranking_rules',
328329
'/reference/api/searchable_attributes',
329330
'/reference/api/sortable_attributes',

.vuepress/public/sample-template.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,6 @@ updating_guide_update_settings_old: |-
147147
updating_guide_add_documents_old: |-
148148
getting_started_typo_tolerance: |-
149149
settings_guide_pagination_1: |-
150+
get_pagination_settings_1: |-
151+
update_pagination_settings_1: |-
152+
reset_pagination_settings_1: |-

learn/advanced/known_limitations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,6 @@ user = 1 OR user = 2 […] OR user = 1500 OR user = 1501 […] OR user = 2000 OR
9797

9898
## Maximum number of results per search
9999

100-
**Limitation:** Meilisearch returns up to 1000 documents per search.
100+
**Limitation:** By default, Meilisearch returns up to 1000 documents per search.
101101

102-
**Explanation:** This non-customizable limit ensures the database is protected from malicious scraping. This limit only applies to the [search route](/reference/api/search.md). If you want to get all documents in your database, you can use the [get documents endpoint](/reference/api/documents.md#get-documents) instead.
102+
**Explanation:** Meilisearch limits the maximum amount of returned search results to protect your database from malicious scraping. You may change this by using the `maxTotalHits` property of the [pagination index settings](/reference/api/pagination.md#maxtotalhits). `maxTotalHits` only applies to the [search route](/reference/api/search.md) and has no effect on the [get documents endpoint](/reference/api/documents.md#get-documents).

reference/api/pagination.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Pagination
2+
3+
_Child route of the [settings route](/reference/api/settings.md)._
4+
5+
This route allows you to configure the pagination settings for an index.
6+
7+
Pagination settings can also be updated directly through the [global settings route](/reference/api/settings.md#update-settings) along with the other settings.
8+
9+
To learn more about paginating search results with Meilisearch, refer to our [dedicated guide](/learn/advanced/pagination.md).
10+
11+
::: warning
12+
Updating the settings means overwriting the default settings of Meilisearch. You can reset to default values using the `DELETE` routes.
13+
:::
14+
15+
## Get pagination settings
16+
17+
<RouteHighlighter method="GET" route="/indexes/{index_uid}/settings/pagination"/>
18+
19+
Get the pagination settings of an index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.
20+
21+
### Example
22+
23+
<CodeSamples id="get_pagination_settings_1" />
24+
25+
#### Response: `200 OK`
26+
27+
```json
28+
{
29+
"maxTotalHits": 1000
30+
}
31+
```
32+
33+
### Returned fields
34+
35+
#### `maxTotalHits`
36+
37+
The maximum number of results Meilisearch can return.
38+
39+
## Update pagination settings
40+
41+
<RouteHighlighter method="PATCH" route="/indexes/{index_uid}/settings/pagination"/>
42+
43+
Partially update the pagination settings for an index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.
44+
45+
### Body
46+
47+
#### `maxTotalHits`
48+
49+
**Type:** integer
50+
**Default value:** `1000`
51+
52+
An integer indicating the maximum number of search results Meilisearch can return. `maxTotalHits` takes priority over search parameters such as `limit` and `offset`.
53+
54+
For example, if you set `maxTotalHits` to 100, you will not be able to access search results beyond 100 no matter the value configured for `offset`.
55+
56+
::: note
57+
Setting `maxTotalHits` to a high value might negatively impact performance and expose instance data to malicious scraping.
58+
:::
59+
60+
#### Example
61+
62+
<CodeSamples id="update_pagination_settings_1" />
63+
64+
#### Response: `200 OK`
65+
66+
```json
67+
{
68+
"taskUid": 1,
69+
"indexUid": "books",
70+
"status": "enqueued",
71+
"type": "settingsUpdate",
72+
"enqueuedAt": "2022-04-14T20:56:44.991039Z"
73+
}
74+
```
75+
76+
You can use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).
77+
78+
## Reset pagination settings
79+
80+
Reset an index's pagination settings to their default value. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.
81+
82+
#### Example
83+
84+
<CodeSamples id="reset_pagination_settings_1" />
85+
86+
#### Response: `200 OK`
87+
88+
```json
89+
{
90+
"taskUid": 1,
91+
"indexUid": "books",
92+
"status": "enqueued",
93+
"type": "settingsUpdate",
94+
"enqueuedAt": "2022-04-14T20:53:32.863107Z"
95+
}
96+
```
97+
98+
You can use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).

reference/api/search.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Other than the differences mentioned above, the two routes are strictly equivale
2020
Search for documents matching a specific query in the given index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.
2121

2222
::: note
23-
This endpoint has a [non-customizable limit of 1000 results](/learn/advanced/known_limitations.md#maximum-number-of-results-per-search). If you want to scrape your database, use the [get documents endpoint](/reference/api/documents.md#get-documents) instead.
23+
By default, [this endpoint returns a maximum of 1000 results](/learn/advanced/known_limitations.md#maximum-number-of-results-per-search). If you want to scrape your database, use the [get documents endpoint](/reference/api/documents.md#get-documents) instead.
2424
:::
2525

2626
This is the preferred route to perform search when an API key is required, as it allows for [preflight requests](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request) to be cached. Caching preflight requests **considerably improves search speed**.
@@ -111,7 +111,7 @@ Query terms enclosed in double quotes are treated as [phrase searches](#query-q)
111111
Search for documents matching a specific query in the given index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.
112112

113113
:::note
114-
This endpoint has a [non-customizable limit of 1000 results](/learn/advanced/known_limitations.md#maximum-number-of-results-per-search). If you want to scrape your database, you can use the [get documents endpoint](/reference/api/documents.md#get-documents) instead.
114+
By default, [this endpoint returns a maximum of 1000 results](/learn/advanced/known_limitations.md#maximum-number-of-results-per-search). If you want to scrape your database, use the [get documents endpoint](/reference/api/documents.md#get-documents) instead.
115115
:::
116116

117117
This route should only be used when no API key is required. If an API key is required, use the POST route instead.

0 commit comments

Comments
 (0)