Skip to content

v0.28: Pagination settings #1759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
693de12
pagination settings: API reference scaffolding
guimachiavelli Jun 23, 2022
6d624d5
pagination: new API reference page
guimachiavelli Jun 27, 2022
b2c4659
pagination: new API code samples
guimachiavelli Jun 27, 2022
dcd96bb
pagination: fix code sample key
guimachiavelli Jun 27, 2022
6ce7068
pagination: add API reference to menu
guimachiavelli Jun 27, 2022
88e9fc5
pagination: update global settings reference
guimachiavelli Jun 27, 2022
aec2da0
pagination: update known limitations
guimachiavelli Jun 28, 2022
b0572e0
pagination: update HTTP method
guimachiavelli Jun 28, 2022
1e88a91
Apply suggestions from code review
guimachiavelli Jun 29, 2022
df1d260
pagination settings: address review feedback
guimachiavelli Jun 29, 2022
f5653cf
pagination settings: improve note on side effects of high `maxTotalHits`
guimachiavelli Jun 29, 2022
2e8e715
pagination settings: fix broken hash
guimachiavelli Jun 29, 2022
b397e1f
pagination settings: update boxes with warnings on non-customizable m…
guimachiavelli Jun 29, 2022
6a618ad
Update reference/api/pagination.md
guimachiavelli Jun 30, 2022
f48fe20
Update reference/api/pagination.md
guimachiavelli Jun 30, 2022
213c326
Add pagination to core concepts/indexes
maryamsulemani97 Jun 30, 2022
0a340c2
Update learn/core_concepts/indexes.md
maryamsulemani97 Jun 30, 2022
752f0b3
Update indexes.md
maryamsulemani97 Jun 30, 2022
511f904
update setings
maryamsulemani97 Jun 30, 2022
8d01e10
settings_guide_pagination_1
maryamsulemani97 Jun 30, 2022
085dcb4
Update .code-samples.meilisearch.yaml
maryamsulemani97 Jun 30, 2022
486e470
Update learn/core_concepts/indexes.md
maryamsulemani97 Jun 30, 2022
31a1443
Apply suggestions from code review
guimachiavelli Jul 4, 2022
4827ac3
Update .code-samples.meilisearch.yaml
guimachiavelli Jul 4, 2022
4257e90
Update .code-samples.meilisearch.yaml
guimachiavelli Jul 4, 2022
3d3d3de
add return to code samples file
guimachiavelli Jul 4, 2022
24a46eb
Merge branch 'v0.28-pagination-settings' into update-indexes.md-to-ad…
guimachiavelli Jul 4, 2022
16b334d
Merge #1766
bors[bot] Jul 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ update_settings_1: |-
"twoTypos": 10
},
"disableOnAttributes": ["title"]
},
"pagination": {
"maxTotalHits": 5000
}
}'
reset_settings_1: |-
Expand Down Expand Up @@ -958,3 +961,16 @@ getting_started_typo_tolerance: |-
--data-binary '{
"minWordSizeForTypos": { "oneTypo": 4 }
}'
get_pagination_settings_1: |-
curl \
-X GET 'http://localhost:7700/indexes/books/settings/pagination'
update_pagination_settings_1: |-
curl \
-X PATCH 'http://localhost:7700/indexes/books/settings/pagination' \
-H 'Content-Type: application/json' \
--data-binary '{
"maxTotalHits": 100
}'
reset_pagination_settings_1: |-
curl \
-X DELETE 'http://localhost:7700/indexes/books/settings/pagination'
1 change: 1 addition & 0 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ module.exports = {
'/reference/api/displayed_attributes',
'/reference/api/distinct_attribute',
'/reference/api/filterable_attributes',
'/reference/api/pagination',
'/reference/api/ranking_rules',
'/reference/api/searchable_attributes',
'/reference/api/sortable_attributes',
Expand Down
3 changes: 3 additions & 0 deletions .vuepress/public/sample-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,6 @@ updating_guide_retrieve_documents_old: |-
updating_guide_update_settings_old: |-
updating_guide_add_documents_old: |-
getting_started_typo_tolerance: |-
get_pagination_settings_1: |-
update_pagination_settings_1: |-
reset_pagination_settings_1: |-
4 changes: 2 additions & 2 deletions learn/advanced/known_limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ user = 1 OR user = 2 […] OR user = 1500 OR user = 1501 […] OR user = 2000 OR

## Maximum number of results per search

**Limitation:** Meilisearch returns up to 1000 documents per search.
**Limitation:** By default, Meilisearch returns up to 1000 documents per search.

**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.
**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-1). `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).
94 changes: 94 additions & 0 deletions reference/api/pagination.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Pagination

_Child route of the [settings route](/reference/api/settings.md)._

This route allows you to configure the pagination settings for an index.

Pagination settings can also be updated directly through the [global settings route](/reference/api/settings.md#update-settings) along with the other settings.

To learn more about paginating search results with Meilisearch, refer to our [dedicated guide](/learn/advanced/pagination.md).

::: warning
Updating the settings means overwriting the default settings of Meilisearch. You can reset to default values using the `DELETE` routes.
:::

## Get pagination settings

<RouteHighlighter method="GET" route="/indexes/{index_uid}/settings/pagination"/>

Get the pagination settings of an index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.

### Example

<CodeSamples id="get_pagination_settings_1" />

#### Response: `200 OK`

```json
{
"maxTotalHits": 1000
}
```

### Returned fields

#### `maxTotalHits`

The maximum number of results Meilisearch can return.

## Update pagination settings

<RouteHighlighter method="PATCH" route="/indexes/{index_uid}/settings/pagination"/>

Partially update the pagination settings for an index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.

### Body

#### `maxTotalHits`

**Type:** integer
**Default value:** `1000`

An integer indicating the maximum number of search results Meilisearch can return. `maxTotalHits` takes priority over search parameters such as `limit` and `offset`.

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`.

#### Example

<CodeSamples id="update_pagination_settings_1" />

#### Response: `200 OK`

```json
{
"uid": 1,
"indexUid": "books",
"status": "enqueued",
"type": "settingsUpdate",
"enqueuedAt": "2022-04-14T20:56:44.991039Z"
}
```

You can use the returned `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).

## Reset pagination settings

Reset an index's pagination settings to their default value. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required.

#### Example

<CodeSamples id="reset_pagination_settings_1" />

#### Response: `200 OK`

```json
{
"uid": 1,
"indexUid": "books",
"status": "enqueued",
"type": "settingsUpdate",
"enqueuedAt": "2022-04-14T20:53:32.863107Z"
}
```

You can use the returned `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).
Loading