|
| 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). |
0 commit comments