From 693de12bb7704b9773e910430bd29b39ffd29fb5 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Thu, 23 Jun 2022 18:13:55 +0200 Subject: [PATCH 01/26] pagination settings: API reference scaffolding --- reference/api/pagination.md | 90 +++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 reference/api/pagination.md diff --git a/reference/api/pagination.md b/reference/api/pagination.md new file mode 100644 index 0000000000..89fc2b8695 --- /dev/null +++ b/reference/api/pagination.md @@ -0,0 +1,90 @@ +# 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 + + + +Get the pagination settings of an index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required. + +### Example + + + +#### Response: `200 OK` + +```json +{ + +} +``` + +### Returned fields + +#### `field_name` + +[field explanation] + +## Update pagination settings + + + +Partially update the pagination settings for an index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required. + +### Body + +#### `field_name` + +[field explanation] + +#### Example + + + +#### 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 + + + +#### 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). + From 6d624d5e7dddc510c0414019c2232580537b35a5 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Mon, 27 Jun 2022 16:30:05 +0200 Subject: [PATCH 02/26] pagination: new API reference page --- reference/api/pagination.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/reference/api/pagination.md b/reference/api/pagination.md index 89fc2b8695..c32f29d5cc 100644 --- a/reference/api/pagination.md +++ b/reference/api/pagination.md @@ -6,7 +6,8 @@ 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). + +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. @@ -26,27 +27,29 @@ Get the pagination settings of an index. The index [`uid`](/learn/core_concepts/ ```json { - + "maxTotalHits": 1000 } ``` ### Returned fields -#### `field_name` +#### `maxTotalHits` -[field explanation] +The maximum number of results Meilisearch can return. ## Update pagination settings - + Partially update the pagination settings for an index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required. ### Body -#### `field_name` +#### `maxTotalHits` -[field explanation] +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 @@ -87,4 +90,3 @@ Reset an index's pagination settings to their default value. The index [`uid`](/ ``` You can use the returned `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task). - From b2c4659e87f25a344cfeecc3632ca4d9986f0414 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Mon, 27 Jun 2022 16:30:31 +0200 Subject: [PATCH 03/26] pagination: new API code samples --- .code-samples.meilisearch.yaml | 13 +++++++++++++ .vuepress/public/sample-template.yaml | 3 +++ 2 files changed, 16 insertions(+) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 047cb60b9f..5bc68e942c 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -958,3 +958,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 POST 'http://localhost:7700/indexes/books/settings/pagination' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "maxTotalHits": 100 + }' +reset_typo_tolerance_1: |- + curl \ + -X DELETE 'http://localhost:7700/indexes/books/settings/pagination' \ No newline at end of file diff --git a/.vuepress/public/sample-template.yaml b/.vuepress/public/sample-template.yaml index 8b52eec657..544cf8048b 100644 --- a/.vuepress/public/sample-template.yaml +++ b/.vuepress/public/sample-template.yaml @@ -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_typo_tolerance_1: |- \ No newline at end of file From dcd96bb37cd0f28dbee011ce2f1b24df04d589cf Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Mon, 27 Jun 2022 16:44:59 +0200 Subject: [PATCH 04/26] pagination: fix code sample key --- .code-samples.meilisearch.yaml | 2 +- .vuepress/public/sample-template.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 5bc68e942c..fd60dc3c2f 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -968,6 +968,6 @@ update_pagination_settings_1: |- --data-binary '{ "maxTotalHits": 100 }' -reset_typo_tolerance_1: |- +reset_pagination_settings_1: |- curl \ -X DELETE 'http://localhost:7700/indexes/books/settings/pagination' \ No newline at end of file diff --git a/.vuepress/public/sample-template.yaml b/.vuepress/public/sample-template.yaml index 544cf8048b..e9e857c693 100644 --- a/.vuepress/public/sample-template.yaml +++ b/.vuepress/public/sample-template.yaml @@ -148,4 +148,4 @@ updating_guide_add_documents_old: |- getting_started_typo_tolerance: |- get_pagination_settings_1: |- update_pagination_settings_1: |- -reset_typo_tolerance_1: |- \ No newline at end of file +reset_pagination_settings_1: |- From 6ce706895cd748c6ae67e50e2434c7165846c2c9 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Mon, 27 Jun 2022 16:50:50 +0200 Subject: [PATCH 05/26] pagination: add API reference to menu --- .vuepress/config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.vuepress/config.js b/.vuepress/config.js index 395bd548d8..c88b11d36c 100644 --- a/.vuepress/config.js +++ b/.vuepress/config.js @@ -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', From 88e9fc5ea8b1a98093880053d7f97b6c1f41ff55 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Mon, 27 Jun 2022 17:29:25 +0200 Subject: [PATCH 06/26] pagination: update global settings reference --- .code-samples.meilisearch.yaml | 3 ++ reference/api/pagination.md | 8 ++-- reference/api/settings.md | 83 ++++++++++++++++++---------------- 3 files changed, 53 insertions(+), 41 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index fd60dc3c2f..7f1a2450b1 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -183,6 +183,9 @@ update_settings_1: |- "twoTypos": 10 }, "disableOnAttributes": ["title"] + }, + "pagination": { + "maxTotalHits": 5000 } }' reset_settings_1: |- diff --git a/reference/api/pagination.md b/reference/api/pagination.md index c32f29d5cc..e4e066488a 100644 --- a/reference/api/pagination.md +++ b/reference/api/pagination.md @@ -6,7 +6,6 @@ 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 @@ -47,9 +46,12 @@ Partially update the pagination settings for an index. The index [`uid`](/learn/ #### `maxTotalHits` -An integer indicating the maximum number of search results Meilisearch can return. +**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`. -`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`. +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 diff --git a/reference/api/settings.md b/reference/api/settings.md index 2d22e9b45b..c474bf25d7 100644 --- a/reference/api/settings.md +++ b/reference/api/settings.md @@ -7,6 +7,7 @@ These are the reference pages for the child routes: - [Displayed attributes](/reference/api/displayed_attributes.md) - [Distinct attribute](/reference/api/distinct_attribute.md) - [Filterable attributes](/reference/api/filterable_attributes.md) +- [Pagination](/reference/api/pagination.md) - [Ranking rules](/reference/api/ranking_rules.md) - [Searchable attributes](/reference/api/searchable_attributes.md) - [Sortable attributes](/reference/api/sortable_attributes.md) @@ -30,17 +31,18 @@ Get the settings of an index. The index [`uid`](/learn/core_concepts/indexes.md# ### Response body -| Variable | Type | Description | Default value | -| ------------------------ | --------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -| **displayedAttributes** | [Strings] | Fields displayed in the returned documents | `["*"]` (all attributes) | -| **distinctAttribute** | String | Search returns documents with distinct (different) values of the given field | `null` | -| **filterableAttributes** | [Strings] | Attributes to use as [filters and facets](/learn/advanced/filtering_and_faceted_search.md) | `[]` | -| **rankingRules** | [Strings] | List of ranking rules sorted by order of importance | [A list of ordered built-in ranking rules](/learn/core_concepts/relevancy.md#built-in-rules) | -| **searchableAttributes** | [Strings] | Fields in which to search for matching query words sorted by order of importance | `["*"]` (all attributes) | -| **sortableAttributes** | [Strings] | Attributes to use when [sorting](/learn/advanced/sorting.md) search results | `[]` | -| **stopWords** | [Strings] | List of words ignored by Meilisearch when present in search queries | `[]` | -| **synonyms** | Object | List of associated words treated similarly | `{}` | -| **typoTolerance** | Object | Typo tolerance settings | `{}` | +| Variable | Type | Description | Default value | +| ------------------------ | --------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- | +| **displayedAttributes** | [Strings] | Fields displayed in the returned documents | `["*"]` (all attributes) | +| **distinctAttribute** | String | Search returns documents with distinct (different) values of the given field | `null` | +| **filterableAttributes** | [Strings] | Attributes to use as [filters and facets](/learn/advanced/filtering_and_faceted_search.md) | `[]` | +| **pagination** | Object | Pagination settings | `{}` | +| **rankingRules** | [Strings] | List of ranking rules sorted by order of importance | [A list of ordered built-in ranking rules](/learn/core_concepts/relevancy.md#built-in-rules) | +| **searchableAttributes** | [Strings] | Fields in which to search for matching query words sorted by order of importance | `["*"]` (all attributes) | +| **sortableAttributes** | [Strings] | Attributes to use when [sorting](/learn/advanced/sorting.md) search results | `[]` | +| **stopWords** | [Strings] | List of words ignored by Meilisearch when present in search queries | `[]` | +| **synonyms** | Object | List of associated words treated similarly | `{}` | +| **typoTolerance** | Object | Typo tolerance settings | `{}` | [Learn more about the settings in this guide.](/learn/configuration/settings.md) @@ -92,12 +94,15 @@ List the settings. "typoTolerance": { "enabled": true, "minWordSizeForTypos": { - "oneTypo": 5, - "twoTypos": 10 + "oneTypo": 5, + "twoTypos": 10 }, - "disableOnWords": [], - "disableOnAttributes": [] - } + "disableOnWords": [], + "disableOnAttributes": [] + }, + "pagination": { + "maxTotalHits": 1000 + } } ``` @@ -117,17 +122,18 @@ If the provided index does not exist, it will be created. ### Body -| Variable | Type | Description | Default value | -| ------------------------ | --------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -| **displayedAttributes** | [Strings] | Fields displayed in the returned documents | `["*"]` (all attributes) | -| **distinctAttribute** | String | Search returns documents with distinct (different) values of the given field | `null` | -| **filterableAttributes** | [Strings] | Attributes to use as [filters and facets](/learn/advanced/filtering_and_faceted_search.md) | `[]` | -| **rankingRules** | [Strings] | List of ranking rules sorted by order of importance | [A list of ordered built-in ranking rules](/learn/core_concepts/relevancy.md#built-in-rules) | -| **searchableAttributes** | [Strings] | Fields in which to search for matching query words sorted by order of importance | `["*"]` (all attributes) | -| **sortableAttributes** | [Strings] | Attributes to use when [sorting](/learn/advanced/sorting.md) search results | `[]` | -| **stopWords** | [Strings] | List of words ignored by Meilisearch when present in search queries | `[]` | -| **synonyms** | Object | List of associated words treated similarly | `{}` | -| **typoTolerance** | Object | Typo tolerance settings | `{}` | +| Variable | Type | Description | Default value | +| ------------------------ | --------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- | +| **displayedAttributes** | [Strings] | Fields displayed in the returned documents | `["*"]` (all attributes) | +| **distinctAttribute** | String | Search returns documents with distinct (different) values of the given field | `null` | +| **filterableAttributes** | [Strings] | Attributes to use as [filters and facets](/learn/advanced/filtering_and_faceted_search.md) | `[]` | +| **pagination** | Object | Pagination settings | `{}` | +| **rankingRules** | [Strings] | List of ranking rules sorted by order of importance | [A list of ordered built-in ranking rules](/learn/core_concepts/relevancy.md#built-in-rules) | +| **searchableAttributes** | [Strings] | Fields in which to search for matching query words sorted by order of importance | `["*"]` (all attributes) | +| **sortableAttributes** | [Strings] | Attributes to use when [sorting](/learn/advanced/sorting.md) search results | `[]` | +| **stopWords** | [Strings] | List of words ignored by Meilisearch when present in search queries | `[]` | +| **synonyms** | Object | List of associated words treated similarly | `{}` | +| **typoTolerance** | Object | Typo tolerance settings | `{}` | ### Example @@ -155,17 +161,18 @@ Reset the settings of an index. The index [`uid`](/learn/core_concepts/indexes.m All settings will be reset to their default value. -| Variable | Type | Description | Default value | -| ------------------------ | --------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -| **displayedAttributes** | [Strings] | Fields displayed in the returned documents | `["*"]` (all attributes) | -| **distinctAttribute** | String | Search returns documents with distinct (different) values of the given field | `null` | -| **filterableAttributes** | [Strings] | Attributes to use as [filters and facets](/learn/advanced/filtering_and_faceted_search.md) | `[]` | -| **rankingRules** | [Strings] | List of ranking rules sorted by order of importance | [A list of ordered built-in ranking rules](/learn/core_concepts/relevancy.md#built-in-rules) | -| **searchableAttributes** | [Strings] | Fields in which to search for matching query words sorted by order of importance | `["*"]` (all attributes) | -| **sortableAttributes** | [Strings] | Attributes to use when [sorting](/learn/advanced/sorting.md) search results | `[]` | -| **stopWords** | [Strings] | List of words ignored by Meilisearch when present in search queries | `[]` | -| **synonyms** | Object | List of associated words treated similarly | `{}` | -| **typoTolerance** | Object | Typo tolerance settings | `{}` | +| Variable | Type | Description | Default value | +| ------------------------ | --------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- | +| **displayedAttributes** | [Strings] | Fields displayed in the returned documents | `["*"]` (all attributes) | +| **distinctAttribute** | String | Search returns documents with distinct (different) values of the given field | `null` | +| **filterableAttributes** | [Strings] | Attributes to use as [filters and facets](/learn/advanced/filtering_and_faceted_search.md) | `[]` | +| **pagination** | Object | Pagination settings | `{}` | +| **rankingRules** | [Strings] | List of ranking rules sorted by order of importance | [A list of ordered built-in ranking rules](/learn/core_concepts/relevancy.md#built-in-rules) | +| **searchableAttributes** | [Strings] | Fields in which to search for matching query words sorted by order of importance | `["*"]` (all attributes) | +| **sortableAttributes** | [Strings] | Attributes to use when [sorting](/learn/advanced/sorting.md) search results | `[]` | +| **stopWords** | [Strings] | List of words ignored by Meilisearch when present in search queries | `[]` | +| **synonyms** | Object | List of associated words treated similarly | `{}` | +| **typoTolerance** | Object | Typo tolerance settings | `{}` | [Learn more about the settings](/learn/configuration/settings.md). #### Example From aec2da0bd3ff472abc2772fa2f92871e5feb2ca8 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Tue, 28 Jun 2022 13:38:02 +0200 Subject: [PATCH 07/26] pagination: update known limitations --- learn/advanced/known_limitations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/learn/advanced/known_limitations.md b/learn/advanced/known_limitations.md index e3743423b2..f76033d033 100644 --- a/learn/advanced/known_limitations.md +++ b/learn/advanced/known_limitations.md @@ -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). From b0572e00bf229dd3ca4d3c08896daec2bc0ef2f7 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Tue, 28 Jun 2022 13:57:16 +0200 Subject: [PATCH 08/26] pagination: update HTTP method --- .code-samples.meilisearch.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 7f1a2450b1..509a6303bb 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -966,11 +966,11 @@ get_pagination_settings_1: |- -X GET 'http://localhost:7700/indexes/books/settings/pagination' update_pagination_settings_1: |- curl \ - -X POST 'http://localhost:7700/indexes/books/settings/pagination' \ + -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' \ No newline at end of file + -X DELETE 'http://localhost:7700/indexes/books/settings/pagination' From 1e88a917941a93a399874f86bd1a4927301c0caf Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Wed, 29 Jun 2022 15:56:18 +0200 Subject: [PATCH 09/26] Apply suggestions from code review Co-authored-by: Maryam <90181761+maryamsulemani97@users.noreply.github.com> --- reference/api/pagination.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/api/pagination.md b/reference/api/pagination.md index e4e066488a..1c0cf7aea6 100644 --- a/reference/api/pagination.md +++ b/reference/api/pagination.md @@ -83,7 +83,7 @@ Reset an index's pagination settings to their default value. The index [`uid`](/ ```json { - "uid": 1, + "taskUid": 1, "indexUid": "books", "status": "enqueued", "type": "settingsUpdate", From df1d260d1450dfbe284297af0d53451179699026 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Wed, 29 Jun 2022 16:05:53 +0200 Subject: [PATCH 10/26] pagination settings: address review feedback --- reference/api/pagination.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reference/api/pagination.md b/reference/api/pagination.md index 1c0cf7aea6..48cacdc784 100644 --- a/reference/api/pagination.md +++ b/reference/api/pagination.md @@ -53,6 +53,10 @@ An integer indicating the maximum number of search results Meilisearch can retur 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`. +::: note +Setting `maxTotalHits` to a high value might negatively impact performance. +::: + #### Example @@ -61,7 +65,7 @@ For example, if you set `maxTotalHits` to 100, you will not be able to access se ```json { - "uid": 1, + "taskUid": 1, "indexUid": "books", "status": "enqueued", "type": "settingsUpdate", From f5653cf238eaeb5b00e19d6857925e7825d7e146 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Wed, 29 Jun 2022 16:17:24 +0200 Subject: [PATCH 11/26] pagination settings: improve note on side effects of high `maxTotalHits` --- reference/api/pagination.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/api/pagination.md b/reference/api/pagination.md index 48cacdc784..0e1debe2ce 100644 --- a/reference/api/pagination.md +++ b/reference/api/pagination.md @@ -54,7 +54,7 @@ An integer indicating the maximum number of search results Meilisearch can retur 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`. ::: note -Setting `maxTotalHits` to a high value might negatively impact performance. +Setting `maxTotalHits` to a high value might negatively impact performance and expose instance data to malicious scraping. ::: #### Example From 2e8e715df688e99683c9df1cfb36bce28ad43742 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Wed, 29 Jun 2022 16:21:57 +0200 Subject: [PATCH 12/26] pagination settings: fix broken hash --- learn/advanced/known_limitations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learn/advanced/known_limitations.md b/learn/advanced/known_limitations.md index f76033d033..a383d0420c 100644 --- a/learn/advanced/known_limitations.md +++ b/learn/advanced/known_limitations.md @@ -99,4 +99,4 @@ user = 1 OR user = 2 […] OR user = 1500 OR user = 1501 […] OR user = 2000 OR **Limitation:** By default, Meilisearch returns up to 1000 documents per search. -**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). +**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). From b397e1fd2c5c5d93df57d339d080ae8d392d987b Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Wed, 29 Jun 2022 16:31:39 +0200 Subject: [PATCH 13/26] pagination settings: update boxes with warnings on non-customizable maximum number of results --- reference/api/search.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/api/search.md b/reference/api/search.md index 491fc9aa8b..9d2a036608 100644 --- a/reference/api/search.md +++ b/reference/api/search.md @@ -20,7 +20,7 @@ Other than the differences mentioned above, the two routes are strictly equivale Search for documents matching a specific query in the given index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required. ::: note -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. +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. ::: 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) Search for documents matching a specific query in the given index. The index [`uid`](/learn/core_concepts/indexes.md#index-uid) is required. :::note -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. +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. ::: This route should only be used when no API key is required. If an API key is required, use the POST route instead. From 6a618ad0f5f6810a5516b8b1f3306692d2921fb2 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Thu, 30 Jun 2022 12:37:16 +0200 Subject: [PATCH 14/26] Update reference/api/pagination.md Co-authored-by: Maryam <90181761+maryamsulemani97@users.noreply.github.com> --- reference/api/pagination.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/api/pagination.md b/reference/api/pagination.md index 0e1debe2ce..485e99c916 100644 --- a/reference/api/pagination.md +++ b/reference/api/pagination.md @@ -73,7 +73,7 @@ Setting `maxTotalHits` to a high value might negatively impact performance and e } ``` -You can use the returned `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task). +You can use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-task). ## Reset pagination settings From f48fe20541a3b129dad1a23c135ea9ef54fa3e27 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Thu, 30 Jun 2022 12:37:30 +0200 Subject: [PATCH 15/26] Update reference/api/pagination.md Co-authored-by: Maryam <90181761+maryamsulemani97@users.noreply.github.com> --- reference/api/pagination.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/api/pagination.md b/reference/api/pagination.md index 485e99c916..f4d15d47b8 100644 --- a/reference/api/pagination.md +++ b/reference/api/pagination.md @@ -95,4 +95,4 @@ Reset an index's pagination settings to their default value. The index [`uid`](/ } ``` -You can use the returned `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task). +You can use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-task). From 213c326c11ec7b1331adc9382b00515d8af6a25c Mon Sep 17 00:00:00 2001 From: Maryam Sulemani Date: Thu, 30 Jun 2022 14:38:14 +0400 Subject: [PATCH 16/26] Add pagination to core concepts/indexes --- learn/core_concepts/indexes.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/learn/core_concepts/indexes.md b/learn/core_concepts/indexes.md index 36f069949e..600bcd2c63 100644 --- a/learn/core_concepts/indexes.md +++ b/learn/core_concepts/indexes.md @@ -59,6 +59,7 @@ You can customize the following index settings: - [Stop words](#stop-words) - [Displayed and searchable attributes](#displayed-and-searchable-attributes) - [Typo tolerance](#typo-tolerance) +- [Pagination](#pagination) To change index settings, use the [update settings endpoint](/reference/api/settings.md#update-settings) or any of the [child routes](/reference/api/settings.md#all-settings). @@ -130,3 +131,11 @@ Typo tolerance is a built-in feature that helps you find relevant results even w You can update the typo tolerance settings using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update typo tolerance endpoint](/reference/api/typo_tolerance.md#update-typo-tolerance). [Learn more about typo tolerance](/learn/configuration/typo_tolerance.md) + +### Pagination + +To protect your database from malicious scraping, Meilisearch returns upto 1000 results for a search query. You can update this using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update pagination settings endpoint](/reference/api/pagination.md#update-pagination-settings). + +We recommend using the [`limit`](/reference/api/search.md#limit) and [`offset`](/reference/api/search.md#offset) search parameters to implement previous and next buttons for a pagination UI. + +[Learn more about pagination](/learn/advanced/pagination.md) From 0a340c234a8b3810394623a4a580fb5dfe7142e5 Mon Sep 17 00:00:00 2001 From: Maryam <90181761+maryamsulemani97@users.noreply.github.com> Date: Thu, 30 Jun 2022 15:23:55 +0400 Subject: [PATCH 17/26] Update learn/core_concepts/indexes.md Co-authored-by: gui machiavelli --- learn/core_concepts/indexes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learn/core_concepts/indexes.md b/learn/core_concepts/indexes.md index 600bcd2c63..82f89e944a 100644 --- a/learn/core_concepts/indexes.md +++ b/learn/core_concepts/indexes.md @@ -134,7 +134,7 @@ You can update the typo tolerance settings using the [update settings endpoint]( ### Pagination -To protect your database from malicious scraping, Meilisearch returns upto 1000 results for a search query. You can update this using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update pagination settings endpoint](/reference/api/pagination.md#update-pagination-settings). +To protect your database from malicious scraping, Meilisearch only returns up to 1000 results for a search query. You can change this limit using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update pagination settings endpoint](/reference/api/pagination.md#update-pagination-settings). We recommend using the [`limit`](/reference/api/search.md#limit) and [`offset`](/reference/api/search.md#offset) search parameters to implement previous and next buttons for a pagination UI. From 752f0b3f0cf4820d5b112f839214caa3004646a2 Mon Sep 17 00:00:00 2001 From: Maryam <90181761+maryamsulemani97@users.noreply.github.com> Date: Thu, 30 Jun 2022 15:24:43 +0400 Subject: [PATCH 18/26] Update indexes.md --- learn/core_concepts/indexes.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/learn/core_concepts/indexes.md b/learn/core_concepts/indexes.md index 82f89e944a..41ad38db86 100644 --- a/learn/core_concepts/indexes.md +++ b/learn/core_concepts/indexes.md @@ -136,6 +136,4 @@ You can update the typo tolerance settings using the [update settings endpoint]( To protect your database from malicious scraping, Meilisearch only returns up to 1000 results for a search query. You can change this limit using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update pagination settings endpoint](/reference/api/pagination.md#update-pagination-settings). -We recommend using the [`limit`](/reference/api/search.md#limit) and [`offset`](/reference/api/search.md#offset) search parameters to implement previous and next buttons for a pagination UI. - [Learn more about pagination](/learn/advanced/pagination.md) From 511f90451ae52f15211e645ee2b842d3fe47b1dd Mon Sep 17 00:00:00 2001 From: Maryam Sulemani Date: Thu, 30 Jun 2022 16:48:49 +0400 Subject: [PATCH 19/26] update setings --- .code-samples.meilisearch.yaml | 7 +++++++ .vuepress/public/sample-template.yaml | 1 + learn/configuration/settings.md | 17 +++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 047cb60b9f..b13b1ae4d0 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -958,3 +958,10 @@ getting_started_typo_tolerance: |- --data-binary '{ "minWordSizeForTypos": { "oneTypo": 4 } }' +. + curl \ + -X PATCH 'http://localhost:7700/indexes/movies/settings/pagination' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "maxTotalHits": 100 + }' \ No newline at end of file diff --git a/.vuepress/public/sample-template.yaml b/.vuepress/public/sample-template.yaml index 8b52eec657..2d1ad7ecd8 100644 --- a/.vuepress/public/sample-template.yaml +++ b/.vuepress/public/sample-template.yaml @@ -146,3 +146,4 @@ updating_guide_retrieve_documents_old: |- updating_guide_update_settings_old: |- updating_guide_add_documents_old: |- getting_started_typo_tolerance: |- +settings_guide_pagination_1: |- \ No newline at end of file diff --git a/learn/configuration/settings.md b/learn/configuration/settings.md index a0380f432d..82860a2eca 100644 --- a/learn/configuration/settings.md +++ b/learn/configuration/settings.md @@ -7,6 +7,7 @@ This page describes the **index-level settings** available in Meilisearch and ho | **[displayedAttributes](/learn/configuration/settings.md#displayed-attributes)** | Fields displayed in the returned documents | All attributes found in the documents | | **[distinctAttribute](/learn/configuration/settings.md#distinct-attribute)** | Search returns documents with distinct (different) values of the given field | `null` | | **[filterableAttributes](/learn/configuration/settings.md#filterable-attributes)** | List of attributes that can be used for filtering | `null` | +| **[pagination](/learn/advanced/pagination.md)** | Pagination settings | `{}` | **[rankingRules](/learn/configuration/settings.md#ranking-rules)** | List of ranking rules sorted by order of importance | [A list of ordered built-in ranking rules](/learn/core_concepts/relevancy.md#built-in-rules) | | **[searchableAttributes](/learn/configuration/settings.md#searchable-attributes)** | Fields in which to search for matching query words sorted by order of importance | All attributes found in the documents | | | **[sortableAttributes](/learn/configuration/settings.md#sortable-attributes)** | List of attributes to use when sorting search results | `[]` | @@ -95,6 +96,22 @@ To be able to filter search results on `director` and `genres` in a movie databa +## Pagination + +The maximum number of results Meilisearch can return. By default, this value is `1000` which means you cannot access results beyond `1000`. + +[Learn more about pagination in our dedicated guide.](/learn/advanced/pagination.md) + +### Example + +The code sample below updates `maxTotalHits` to `50`: + + + +::: note +`maxTotalHits` takes priority over search parameters such as [`limit`](/reference/api/search.md#limit) and [`offset`](/reference/api/search.md#offset). +::: + ## Ranking rules Built-in ranking rules that **ensure relevancy in search results**. Ranking rules are applied in a default order which can be changed in the settings. You can add or remove rules and change their order of importance. From 8d01e108a525964c2d714c3eeb7fa1daf6a607ec Mon Sep 17 00:00:00 2001 From: Maryam Sulemani Date: Thu, 30 Jun 2022 16:51:11 +0400 Subject: [PATCH 20/26] settings_guide_pagination_1 --- .code-samples.meilisearch.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index b13b1ae4d0..b6769bcec9 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -958,7 +958,7 @@ getting_started_typo_tolerance: |- --data-binary '{ "minWordSizeForTypos": { "oneTypo": 4 } }' -. +settings_guide_pagination_1: |- curl \ -X PATCH 'http://localhost:7700/indexes/movies/settings/pagination' \ -H 'Content-Type: application/json' \ From 085dcb46c14e5997cca0f8fd15be3c1bcbd73517 Mon Sep 17 00:00:00 2001 From: Maryam <90181761+maryamsulemani97@users.noreply.github.com> Date: Thu, 30 Jun 2022 16:52:35 +0400 Subject: [PATCH 21/26] Update .code-samples.meilisearch.yaml --- .code-samples.meilisearch.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index b6769bcec9..530540c2db 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -963,5 +963,5 @@ settings_guide_pagination_1: |- -X PATCH 'http://localhost:7700/indexes/movies/settings/pagination' \ -H 'Content-Type: application/json' \ --data-binary '{ - "maxTotalHits": 100 + "maxTotalHits": 50 }' \ No newline at end of file From 486e470fc4306b5d69c10dffb07a1af0d28e856c Mon Sep 17 00:00:00 2001 From: Maryam <90181761+maryamsulemani97@users.noreply.github.com> Date: Thu, 30 Jun 2022 17:27:11 +0400 Subject: [PATCH 22/26] Update learn/core_concepts/indexes.md --- learn/core_concepts/indexes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learn/core_concepts/indexes.md b/learn/core_concepts/indexes.md index 41ad38db86..c32a7f8309 100644 --- a/learn/core_concepts/indexes.md +++ b/learn/core_concepts/indexes.md @@ -134,6 +134,6 @@ You can update the typo tolerance settings using the [update settings endpoint]( ### Pagination -To protect your database from malicious scraping, Meilisearch only returns up to 1000 results for a search query. You can change this limit using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update pagination settings endpoint](/reference/api/pagination.md#update-pagination-settings). +To protect your database from malicious scraping, Meilisearch only returns up to `1000` results for a search query. You can change this limit using the [update settings endpoint](/reference/api/settings.md#update-settings) or the [update pagination settings endpoint](/reference/api/pagination.md#update-pagination-settings). [Learn more about pagination](/learn/advanced/pagination.md) From 31a144341d56ac7a27c33fb515b2c2300f794704 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Mon, 4 Jul 2022 13:00:03 +0200 Subject: [PATCH 23/26] Apply suggestions from code review --- .code-samples.meilisearch.yaml | 3 ++- .vuepress/public/sample-template.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 530540c2db..b1c501cd1d 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -964,4 +964,5 @@ settings_guide_pagination_1: |- -H 'Content-Type: application/json' \ --data-binary '{ "maxTotalHits": 50 - }' \ No newline at end of file + }' + \ No newline at end of file diff --git a/.vuepress/public/sample-template.yaml b/.vuepress/public/sample-template.yaml index 2d1ad7ecd8..58cf6ba345 100644 --- a/.vuepress/public/sample-template.yaml +++ b/.vuepress/public/sample-template.yaml @@ -146,4 +146,4 @@ updating_guide_retrieve_documents_old: |- updating_guide_update_settings_old: |- updating_guide_add_documents_old: |- getting_started_typo_tolerance: |- -settings_guide_pagination_1: |- \ No newline at end of file +settings_guide_pagination_1: |- From 4827ac35d7ceb4cb09404f40a08c49e864337a16 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Mon, 4 Jul 2022 13:00:35 +0200 Subject: [PATCH 24/26] Update .code-samples.meilisearch.yaml --- .code-samples.meilisearch.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index b1c501cd1d..530540c2db 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -964,5 +964,4 @@ settings_guide_pagination_1: |- -H 'Content-Type: application/json' \ --data-binary '{ "maxTotalHits": 50 - }' - \ No newline at end of file + }' \ No newline at end of file From 4257e9066200d8c2ad6d2ea893acac8d5acfd231 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Mon, 4 Jul 2022 13:00:52 +0200 Subject: [PATCH 25/26] Update .code-samples.meilisearch.yaml --- .code-samples.meilisearch.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 530540c2db..86ff7b1453 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -964,4 +964,5 @@ settings_guide_pagination_1: |- -H 'Content-Type: application/json' \ --data-binary '{ "maxTotalHits": 50 - }' \ No newline at end of file + }' + \ No newline at end of file From 3d3d3de845ead0d189c90c9d397966a684cb4e93 Mon Sep 17 00:00:00 2001 From: gui machiavelli Date: Mon, 4 Jul 2022 13:02:24 +0200 Subject: [PATCH 26/26] add return to code samples file --- .code-samples.meilisearch.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 86ff7b1453..3253d71579 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -965,4 +965,3 @@ settings_guide_pagination_1: |- --data-binary '{ "maxTotalHits": 50 }' - \ No newline at end of file