From 1da54a3d4e339aafb1d4706a2e8c7cd86a4c0f38 Mon Sep 17 00:00:00 2001 From: Maryam Sulemani Date: Tue, 6 Sep 2022 15:04:03 +0400 Subject: [PATCH 1/8] update tables --- reference/api/search.md | 73 +++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/reference/api/search.md b/reference/api/search.md index 7c4bf4cbd7..13ad569b60 100644 --- a/reference/api/search.md +++ b/reference/api/search.md @@ -33,22 +33,23 @@ By default, [this endpoint returns a maximum of 1000 results](/learn/advanced/kn ### Body -| Search Parameter | Type | Default value | Description | -| :------------------------------------------------------ | :--------------- | :------------ | :------------------------------------------------- | -| **[`q`](#query-q)** | String | `""` | Query string | -| **[`offset`](#offset)** | Integer | `0` | Number of documents to skip | -| **[`limit`](#limit)** | Integer | `20` | Maximum number of documents returned | -| **[`filter`](#filter)** | Array of strings | `null` | Filter queries by an attribute's value | -| **[`facets`](#facets)** | Array of strings | `null` | Display the count of matches per facet | -| **[`attributesToRetrieve`](#attributes-to-retrieve)** | Array of strings | `["*"]` | Attributes to display in the returned documents | -| **[`attributesToCrop`](#attributes-to-crop)** | Array od strings | `null` | Attributes whose values have to be cropped | -| **[`cropLength`](#crop-length)** | Integer | `10` | Maximum length of cropped value in words | -| **[`cropMarker`](#crop-marker)** | String | `"…"` | String marking crop boundaries | -| **[`attributesToHighlight`](#attributes-to-highlight)** | Array of strings | `null` | Highlight matching terms contained in an attribute | -| **[`highlightPreTag`](#highlight-tags)** | String | `""` | String inserted at the start of a highlighted term | -| **[`highlightPostTag`](#highlight-tags)** | String | `""` | String inserted at the end of a highlighted term | -| **[`showMatchesPosition`](#show-matches-position)** | Boolean | `false` | Return matching terms location | -| **[`sort`](#sort)** | Array of strings | `null` | Sort search results by an attribute's value | +| Search Parameter | Type | Default value | Description | +| :------------------------------------------------------ | :--------------- | :------------ | :-------------------------------------------------------------------- | +| **[`q`](#query-q)** | String | `""` | Query string | +| **[`offset`](#offset)** | Integer | `0` | Number of documents to skip | +| **[`limit`](#limit)** | Integer | `20` | Maximum number of documents returned | +| **[`filter`](#filter)** | Array of strings | `null` | Filter queries by an attribute's value | +| **[`facets`](#facets)** | Array of strings | `null` | Display the count of matches per facet | +| **[`attributesToRetrieve`](#attributes-to-retrieve)** | Array of strings | `["*"]` | Attributes to display in the returned documents | +| **[`attributesToCrop`](#attributes-to-crop)** | Array od strings | `null` | Attributes whose values have to be cropped | +| **[`cropLength`](#crop-length)** | Integer | `10` | Maximum length of cropped value in words | +| **[`cropMarker`](#crop-marker)** | String | `"…"` | String marking crop boundaries | +| **[`attributesToHighlight`](#attributes-to-highlight)** | Array of strings | `null` | Highlight matching terms contained in an attribute | +| **[`highlightPreTag`](#highlight-tags)** | String | `""` | String inserted at the start of a highlighted term | +| **[`highlightPostTag`](#highlight-tags)** | String | `""` | String inserted at the end of a highlighted term | +| **[`showMatchesPosition`](#show-matches-position)** | Boolean | `false` | Return matching terms location | +| **[`sort`](#sort)** | Array of strings | `null` | Sort search results by an attribute's value | +| **[`matchingStrategy`](#matching-strategy)** | String | `last` | Strategy used to match query terms within documents as search results | [Learn more about how to use each search parameter](#search-parameters). @@ -127,22 +128,23 @@ By default, [this endpoint returns a maximum of 1000 results](/learn/advanced/kn ### Query parameters -| Search Parameter | Type | Default value | Description | -| :------------------------------------------------------ | :--------------- | :------------ | :------------------------------------------------- | -| **[`q`](#query-q)** | String | `""` | Query string | -| **[`offset`](#offset)** | Integer | `0` | Number of documents to skip | -| **[`limit`](#limit)** | Integer | `20` | Maximum number of documents returned | -| **[`filter`](#filter)** | Array of strings | `null` | Filter queries by an attribute's value | -| **[`facets`](#facets)** | Array of strings | `null` | Display the count of matches per facet | -| **[`attributesToRetrieve`](#attributes-to-retrieve)** | Array of strings | `["*"]` | Attributes to display in the returned documents | -| **[`attributesToCrop`](#attributes-to-crop)** | Array od strings | `null` | Attributes whose values have to be cropped | -| **[`cropLength`](#crop-length)** | Integer | `10` | Maximum length of cropped value in words | -| **[`cropMarker`](#crop-marker)** | String | `"…"` | String marking crop boundaries | -| **[`attributesToHighlight`](#attributes-to-highlight)** | Array of strings | `null` | Highlight matching terms contained in an attribute | -| **[`highlightPreTag`](#highlight-tags)** | String | `""` | String inserted at the start of a highlighted term | -| **[`highlightPostTag`](#highlight-tags)** | String | `""` | String inserted at the end of a highlighted term | -| **[`showMatchesPosition`](#show-matches-position)** | Boolean | `false` | Return matching terms location | -| **[`sort`](#sort)** | Array of strings | `null` | Sort search results by an attribute's value | +| Search Parameter | Type | Default value | Description | +| :------------------------------------------------------ | :--------------- | :------------ | :-------------------------------------------------------------------- | +| **[`q`](#query-q)** | String | `""` | Query string | +| **[`offset`](#offset)** | Integer | `0` | Number of documents to skip | +| **[`limit`](#limit)** | Integer | `20` | Maximum number of documents returned | +| **[`filter`](#filter)** | Array of strings | `null` | Filter queries by an attribute's value | +| **[`facets`](#facets)** | Array of strings | `null` | Display the count of matches per facet | +| **[`attributesToRetrieve`](#attributes-to-retrieve)** | Array of strings | `["*"]` | Attributes to display in the returned documents | +| **[`attributesToCrop`](#attributes-to-crop)** | Array od strings | `null` | Attributes whose values have to be cropped | +| **[`cropLength`](#crop-length)** | Integer | `10` | Maximum length of cropped value in words | +| **[`cropMarker`](#crop-marker)** | String | `"…"` | String marking crop boundaries | +| **[`attributesToHighlight`](#attributes-to-highlight)** | Array of strings | `null` | Highlight matching terms contained in an attribute | +| **[`highlightPreTag`](#highlight-tags)** | String | `""` | String inserted at the start of a highlighted term | +| **[`highlightPostTag`](#highlight-tags)** | String | `""` | String inserted at the end of a highlighted term | +| **[`showMatchesPosition`](#show-matches-position)** | Boolean | `false` | Return matching terms location | +| **[`sort`](#sort)** | Array of strings | `null` | Sort search results by an attribute's value | +| **[`matchingStrategy`](#matching-strategy)** | String | `last` | Strategy used to match query terms within documents as search results | [Learn more about how to use each search parameter](#search-parameters). @@ -227,6 +229,7 @@ This is not necessary when using the `POST` route or one of our [SDKs](/learn/wh | **[`highlightPostTag`](#highlight-tags)** | `""` | String inserted at the end of a highlighted term | | **[`showMatchesPosition`](#show-matches-position)** | `false` | Return matching terms location | | **[`sort`](#sort)** | `null` | Sort search results by an attribute's value | +| **[`matchingStrategy`](#matching-strategy)** | String | `last` | Strategy used to match query terms within documents as search results ### Query (q) @@ -735,3 +738,9 @@ Queries using `_geoPoint` will always include a `geoDistance` field containing t ``` [You can read more about location-based sorting in our dedicated guide.](/learn/advanced/geosearch.md#sorting-results-with-geopoint) + +### Matching strategy + +**Parameter**: `matchingStrategy` +**Expected value**: `last` or `all` +**Default value**: `last` From 2dcf312ea9ba2d7d27ccf8af5cb0d126e39b1bdb Mon Sep 17 00:00:00 2001 From: Maryam Sulemani Date: Wed, 7 Sep 2022 14:45:45 +0400 Subject: [PATCH 2/8] update search.md --- .code-samples.meilisearch.yaml | 15 ++++ .vuepress/public/sample-template.yaml | 2 + reference/api/search.md | 120 +++++++++++++++----------- 3 files changed, 86 insertions(+), 51 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index adb2a435fe..d17afa72c6 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -986,3 +986,18 @@ getting_started_pagination: |- --data-binary '{ "maxTotalHits": 500 }' +search_parameter_guide_matching_strategy_1: | + curl \ + -X POST 'http://localhost:7700/indexes/movies/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "q": "big fat liar" + }' +search_parameter_guide_matching_strategy_2: | + curl \ + -X POST 'http://localhost:7700/indexes/movies/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "q": "big fat liar", + "matchingStrategy": "all" + }' diff --git a/.vuepress/public/sample-template.yaml b/.vuepress/public/sample-template.yaml index 4a3a78fcc8..04ba936630 100644 --- a/.vuepress/public/sample-template.yaml +++ b/.vuepress/public/sample-template.yaml @@ -152,3 +152,5 @@ synonyms_guide_1: |- getting_started_faceting: |- getting_started_pagination: |- getting_started_front_end_integration_md: |- +search_parameter_guide_matching_strategy_1: |- +search_parameter_guide_matching_strategy_2: |- diff --git a/reference/api/search.md b/reference/api/search.md index 13ad569b60..f4386984c2 100644 --- a/reference/api/search.md +++ b/reference/api/search.md @@ -33,23 +33,23 @@ By default, [this endpoint returns a maximum of 1000 results](/learn/advanced/kn ### Body -| Search Parameter | Type | Default value | Description | -| :------------------------------------------------------ | :--------------- | :------------ | :-------------------------------------------------------------------- | -| **[`q`](#query-q)** | String | `""` | Query string | -| **[`offset`](#offset)** | Integer | `0` | Number of documents to skip | -| **[`limit`](#limit)** | Integer | `20` | Maximum number of documents returned | -| **[`filter`](#filter)** | Array of strings | `null` | Filter queries by an attribute's value | -| **[`facets`](#facets)** | Array of strings | `null` | Display the count of matches per facet | -| **[`attributesToRetrieve`](#attributes-to-retrieve)** | Array of strings | `["*"]` | Attributes to display in the returned documents | -| **[`attributesToCrop`](#attributes-to-crop)** | Array od strings | `null` | Attributes whose values have to be cropped | -| **[`cropLength`](#crop-length)** | Integer | `10` | Maximum length of cropped value in words | -| **[`cropMarker`](#crop-marker)** | String | `"…"` | String marking crop boundaries | -| **[`attributesToHighlight`](#attributes-to-highlight)** | Array of strings | `null` | Highlight matching terms contained in an attribute | -| **[`highlightPreTag`](#highlight-tags)** | String | `""` | String inserted at the start of a highlighted term | -| **[`highlightPostTag`](#highlight-tags)** | String | `""` | String inserted at the end of a highlighted term | -| **[`showMatchesPosition`](#show-matches-position)** | Boolean | `false` | Return matching terms location | -| **[`sort`](#sort)** | Array of strings | `null` | Sort search results by an attribute's value | -| **[`matchingStrategy`](#matching-strategy)** | String | `last` | Strategy used to match query terms within documents as search results | +| Search Parameter | Type | Default value | Description | +| :------------------------------------------------------ | :--------------- | :------------ | :-------------------------------------------------- | +| **[`q`](#query-q)** | String | `""` | Query string | +| **[`offset`](#offset)** | Integer | `0` | Number of documents to skip | +| **[`limit`](#limit)** | Integer | `20` | Maximum number of documents returned | +| **[`filter`](#filter)** | Array of strings | `null` | Filter queries by an attribute's value | +| **[`facets`](#facets)** | Array of strings | `null` | Display the count of matches per facet | +| **[`attributesToRetrieve`](#attributes-to-retrieve)** | Array of strings | `["*"]` | Attributes to display in the returned documents | +| **[`attributesToCrop`](#attributes-to-crop)** | Array od strings | `null` | Attributes whose values have to be cropped | +| **[`cropLength`](#crop-length)** | Integer | `10` | Maximum length of cropped value in words | +| **[`cropMarker`](#crop-marker)** | String | `"…"` | String marking crop boundaries | +| **[`attributesToHighlight`](#attributes-to-highlight)** | Array of strings | `null` | Highlight matching terms contained in an attribute | +| **[`highlightPreTag`](#highlight-tags)** | String | `""` | String inserted at the start of a highlighted term | +| **[`highlightPostTag`](#highlight-tags)** | String | `""` | String inserted at the end of a highlighted term | +| **[`showMatchesPosition`](#show-matches-position)** | Boolean | `false` | Return matching terms location | +| **[`sort`](#sort)** | Array of strings | `null` | Sort search results by an attribute's value | +| **[`matchingStrategy`](#matching-strategy)** | String | `last` | Strategy used to match query terms within documents | [Learn more about how to use each search parameter](#search-parameters). @@ -128,23 +128,23 @@ By default, [this endpoint returns a maximum of 1000 results](/learn/advanced/kn ### Query parameters -| Search Parameter | Type | Default value | Description | -| :------------------------------------------------------ | :--------------- | :------------ | :-------------------------------------------------------------------- | -| **[`q`](#query-q)** | String | `""` | Query string | -| **[`offset`](#offset)** | Integer | `0` | Number of documents to skip | -| **[`limit`](#limit)** | Integer | `20` | Maximum number of documents returned | -| **[`filter`](#filter)** | Array of strings | `null` | Filter queries by an attribute's value | -| **[`facets`](#facets)** | Array of strings | `null` | Display the count of matches per facet | -| **[`attributesToRetrieve`](#attributes-to-retrieve)** | Array of strings | `["*"]` | Attributes to display in the returned documents | -| **[`attributesToCrop`](#attributes-to-crop)** | Array od strings | `null` | Attributes whose values have to be cropped | -| **[`cropLength`](#crop-length)** | Integer | `10` | Maximum length of cropped value in words | -| **[`cropMarker`](#crop-marker)** | String | `"…"` | String marking crop boundaries | -| **[`attributesToHighlight`](#attributes-to-highlight)** | Array of strings | `null` | Highlight matching terms contained in an attribute | -| **[`highlightPreTag`](#highlight-tags)** | String | `""` | String inserted at the start of a highlighted term | -| **[`highlightPostTag`](#highlight-tags)** | String | `""` | String inserted at the end of a highlighted term | -| **[`showMatchesPosition`](#show-matches-position)** | Boolean | `false` | Return matching terms location | -| **[`sort`](#sort)** | Array of strings | `null` | Sort search results by an attribute's value | -| **[`matchingStrategy`](#matching-strategy)** | String | `last` | Strategy used to match query terms within documents as search results | +| Search Parameter | Type | Default value | Description | +| :------------------------------------------------------ | :--------------- | :------------ | :-------------------------------------------------- | +| **[`q`](#query-q)** | String | `""` | Query string | +| **[`offset`](#offset)** | Integer | `0` | Number of documents to skip | +| **[`limit`](#limit)** | Integer | `20` | Maximum number of documents returned | +| **[`filter`](#filter)** | Array of strings | `null` | Filter queries by an attribute's value | +| **[`facets`](#facets)** | Array of strings | `null` | Display the count of matches per facet | +| **[`attributesToRetrieve`](#attributes-to-retrieve)** | Array of strings | `["*"]` | Attributes to display in the returned documents | +| **[`attributesToCrop`](#attributes-to-crop)** | Array od strings | `null` | Attributes whose values have to be cropped | +| **[`cropLength`](#crop-length)** | Integer | `10` | Maximum length of cropped value in words | +| **[`cropMarker`](#crop-marker)** | String | `"…"` | String marking crop boundaries | +| **[`attributesToHighlight`](#attributes-to-highlight)** | Array of strings | `null` | Highlight matching terms contained in an attribute | +| **[`highlightPreTag`](#highlight-tags)** | String | `""` | String inserted at the start of a highlighted term | +| **[`highlightPostTag`](#highlight-tags)** | String | `""` | String inserted at the end of a highlighted term | +| **[`showMatchesPosition`](#show-matches-position)** | Boolean | `false` | Return matching terms location | +| **[`sort`](#sort)** | Array of strings | `null` | Sort search results by an attribute's value | +| **[`matchingStrategy`](#matching-strategy)** | String | `last` | Strategy used to match query terms within documents | [Learn more about how to use each search parameter](#search-parameters). @@ -213,23 +213,23 @@ This is not necessary when using the `POST` route or one of our [SDKs](/learn/wh ### Overview -| Search Parameter | Default value | Description | -| :------------------------------------------------------ | :------------ | :------------------------------------------------- | -| **[`q`](#query-q)** | `""` | Query string | -| **[`offset`](#offset)** | `0` | Number of documents to skip | -| **[`limit`](#limit)** | `20` | Maximum number of documents returned | -| **[`filter`](#filter)** | `null` | Filter queries by an attribute's value | -| **[`facets`](#facets)** | `null` | Display the count of matches per facet | -| **[`attributesToRetrieve`](#attributes-to-retrieve)** | `["*"]` | Attributes to display in the returned documents | -| **[`attributesToCrop`](#attributes-to-crop)** | `null` | Attributes whose values have to be cropped | -| **[`cropLength`](#crop-length)** | `10` | Maximum length of cropped value in words | -| **[`cropMarker`](#crop-marker)** | `"…"` | String marking crop boundaries | -| **[`attributesToHighlight`](#attributes-to-highlight)** | `null` | Highlight matching terms contained in an attribute | -| **[`highlightPreTag`](#highlight-tags)** | `""` | String inserted at the start of a highlighted term | -| **[`highlightPostTag`](#highlight-tags)** | `""` | String inserted at the end of a highlighted term | -| **[`showMatchesPosition`](#show-matches-position)** | `false` | Return matching terms location | -| **[`sort`](#sort)** | `null` | Sort search results by an attribute's value | -| **[`matchingStrategy`](#matching-strategy)** | String | `last` | Strategy used to match query terms within documents as search results +| Search Parameter | Type | Default value | Description | +| :------------------------------------------------------ | :--------------- | :------------ | :-------------------------------------------------- | +| **[`q`](#query-q)** | String | `""` | Query string | +| **[`offset`](#offset)** | Integer | `0` | Number of documents to skip | +| **[`limit`](#limit)** | Integer | `20` | Maximum number of documents returned | +| **[`filter`](#filter)** | Array of strings | `null` | Filter queries by an attribute's value | +| **[`facets`](#facets)** | Array of strings | `null` | Display the count of matches per facet | +| **[`attributesToRetrieve`](#attributes-to-retrieve)** | Array of strings | `["*"]` | Attributes to display in the returned documents | +| **[`attributesToCrop`](#attributes-to-crop)** | Array od strings | `null` | Attributes whose values have to be cropped | +| **[`cropLength`](#crop-length)** | Integer | `10` | Maximum length of cropped value in words | +| **[`cropMarker`](#crop-marker)** | String | `"…"` | String marking crop boundaries | +| **[`attributesToHighlight`](#attributes-to-highlight)** | Array of strings | `null` | Highlight matching terms contained in an attribute | +| **[`highlightPreTag`](#highlight-tags)** | String | `""` | String inserted at the start of a highlighted term | +| **[`highlightPostTag`](#highlight-tags)** | String | `""` | String inserted at the end of a highlighted term | +| **[`showMatchesPosition`](#show-matches-position)** | Boolean | `false` | Return matching terms location | +| **[`sort`](#sort)** | Array of strings | `null` | Sort search results by an attribute's value | +| **[`matchingStrategy`](#matching-strategy)** | String | `last` | Strategy used to match query terms within documents | ### Query (q) @@ -744,3 +744,21 @@ Queries using `_geoPoint` will always include a `geoDistance` field containing t **Parameter**: `matchingStrategy` **Expected value**: `last` or `all` **Default value**: `last` + +Defines the strategy used to match query terms in documents. `last` returns documents containing all the query words first. If there aren't enough documents to meet the requested `limit`, it will remove one query term at a time, starting from the second last query term. + + + +With the above code sample, Meilisearch will first return documents that contain all three words. If the results don't meet the requested `limit`, it will return documents with just `big fat` followed by just `big`. + +`all`, on the other hand, only returns documents that contain all the query words. Meilisearch will not match any more documents even if there aren't enough to meet the requested `limit`. + +Searching for `big fat liar` will only return documents that contain all three words. + + + +The above code sample only returns one result compared to 476 when the `matchingStrategy` was set to `last`. + +::: warning +The number of search results may vary depending on changes to the `movies` dataset. +::: From 470e25570bc444b7e52d2d0f7ca874290ccf075d Mon Sep 17 00:00:00 2001 From: Maryam <90181761+maryamsulemani97@users.noreply.github.com> Date: Wed, 7 Sep 2022 14:50:11 +0400 Subject: [PATCH 3/8] Update reference/api/search.md --- reference/api/search.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/api/search.md b/reference/api/search.md index f4386984c2..9fafe5e37c 100644 --- a/reference/api/search.md +++ b/reference/api/search.md @@ -745,7 +745,7 @@ Queries using `_geoPoint` will always include a `geoDistance` field containing t **Expected value**: `last` or `all` **Default value**: `last` -Defines the strategy used to match query terms in documents. `last` returns documents containing all the query words first. If there aren't enough documents to meet the requested `limit`, it will remove one query term at a time, starting from the second last query term. +Defines the strategy used to match query terms in documents. `last` returns documents containing all the query words first. If there aren't enough documents to meet the requested `limit`, it will remove one query term at a time, starting from the end of the query term. From 789af6d0e3163325fd6d1116a1ad12e4b7b59fc8 Mon Sep 17 00:00:00 2001 From: Maryam <90181761+maryamsulemani97@users.noreply.github.com> Date: Wed, 7 Sep 2022 14:52:28 +0400 Subject: [PATCH 4/8] Update reference/api/search.md --- reference/api/search.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/api/search.md b/reference/api/search.md index 9fafe5e37c..2667787322 100644 --- a/reference/api/search.md +++ b/reference/api/search.md @@ -745,7 +745,7 @@ Queries using `_geoPoint` will always include a `geoDistance` field containing t **Expected value**: `last` or `all` **Default value**: `last` -Defines the strategy used to match query terms in documents. `last` returns documents containing all the query words first. If there aren't enough documents to meet the requested `limit`, it will remove one query term at a time, starting from the end of the query term. +Defines the strategy used to match query terms in documents. `last` returns documents containing all the query words first. If there aren't enough documents to meet the requested `limit`, it will remove one query term at a time, starting from the end of the query. From 81f18af623adc9ac060c28630ed3d2dc2b9dd854 Mon Sep 17 00:00:00 2001 From: Maryam <90181761+maryamsulemani97@users.noreply.github.com> Date: Tue, 20 Sep 2022 12:14:17 +0400 Subject: [PATCH 5/8] Update reference/api/search.md Co-authored-by: gui machiavelli --- reference/api/search.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/api/search.md b/reference/api/search.md index 2667787322..a422952793 100644 --- a/reference/api/search.md +++ b/reference/api/search.md @@ -751,7 +751,7 @@ Defines the strategy used to match query terms in documents. `last` returns docu With the above code sample, Meilisearch will first return documents that contain all three words. If the results don't meet the requested `limit`, it will return documents with just `big fat` followed by just `big`. -`all`, on the other hand, only returns documents that contain all the query words. Meilisearch will not match any more documents even if there aren't enough to meet the requested `limit`. +`all`, on the other hand, only returns documents that contain all query terms. Meilisearch will not match any more documents even if there aren't enough to meet the requested `limit`. Searching for `big fat liar` will only return documents that contain all three words. From 20fb28226fbb15cf9eb221660e2f2a903c8789f8 Mon Sep 17 00:00:00 2001 From: Maryam Sulemani Date: Tue, 20 Sep 2022 12:19:43 +0400 Subject: [PATCH 6/8] update based on review --- reference/api/search.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/reference/api/search.md b/reference/api/search.md index a422952793..ef14c8fb8c 100644 --- a/reference/api/search.md +++ b/reference/api/search.md @@ -751,14 +751,8 @@ Defines the strategy used to match query terms in documents. `last` returns docu With the above code sample, Meilisearch will first return documents that contain all three words. If the results don't meet the requested `limit`, it will return documents with just `big fat` followed by just `big`. -`all`, on the other hand, only returns documents that contain all query terms. Meilisearch will not match any more documents even if there aren't enough to meet the requested `limit`. - -Searching for `big fat liar` will only return documents that contain all three words. +`all`, on the other hand, only returns documents that contain all query terms. Meilisearch will not match any more documents even if there aren't enough to meet the requested `limit`. Searching for `big fat liar` will only return documents that contain all three words. -The above code sample only returns one result compared to 476 when the `matchingStrategy` was set to `last`. - -::: warning -The number of search results may vary depending on changes to the `movies` dataset. -::: +`all` usually returns fewer search results compared to `last`. From 1648faa434787ea38afcbb88362d5d2d1a25d9a5 Mon Sep 17 00:00:00 2001 From: Maryam <90181761+maryamsulemani97@users.noreply.github.com> Date: Tue, 27 Sep 2022 15:43:02 +0400 Subject: [PATCH 7/8] Apply suggestions from code review Co-authored-by: Tommy <68053732+dichotommy@users.noreply.github.com> --- .code-samples.meilisearch.yaml | 3 ++- reference/api/search.md | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index d17afa72c6..a10dce067e 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -991,7 +991,8 @@ search_parameter_guide_matching_strategy_1: | -X POST 'http://localhost:7700/indexes/movies/search' \ -H 'Content-Type: application/json' \ --data-binary '{ - "q": "big fat liar" + "q": "big fat liar", + "matchingStrategy": "last" }' search_parameter_guide_matching_strategy_2: | curl \ diff --git a/reference/api/search.md b/reference/api/search.md index ef14c8fb8c..e2c6d0ecc8 100644 --- a/reference/api/search.md +++ b/reference/api/search.md @@ -745,14 +745,20 @@ Queries using `_geoPoint` will always include a `geoDistance` field containing t **Expected value**: `last` or `all` **Default value**: `last` -Defines the strategy used to match query terms in documents. `last` returns documents containing all the query words first. If there aren't enough documents to meet the requested `limit`, it will remove one query term at a time, starting from the end of the query. +Defines the strategy used to match query terms in documents. + +#### `last` + +`last` returns documents containing all the query terms first. If there are not enough results containing all query terms to meet the requested `limit`, Meilisearch will remove one query term at a time, starting from the end of the query. -With the above code sample, Meilisearch will first return documents that contain all three words. If the results don't meet the requested `limit`, it will return documents with just `big fat` followed by just `big`. +With the above code sample, Meilisearch will first return documents that contain all three words. If the results don't meet the requested `limit`, it will also return documents containing only the first two terms, `big fat`, followed by documents containing only `big`. + +#### `all` -`all`, on the other hand, only returns documents that contain all query terms. Meilisearch will not match any more documents even if there aren't enough to meet the requested `limit`. Searching for `big fat liar` will only return documents that contain all three words. +`all` only returns documents that contain all query terms. Meilisearch will not match any more documents even if there aren't enough to meet the requested `limit`. -`all` usually returns fewer search results compared to `last`. +The above code sample would only return documents containing all three words. From 4e9b8dc4d80ca86634fcb2b506c89a5f47c0fe5e Mon Sep 17 00:00:00 2001 From: Maryam Sulemani Date: Tue, 27 Sep 2022 15:45:42 +0400 Subject: [PATCH 8/8] remove space --- reference/api/search.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/api/search.md b/reference/api/search.md index e2c6d0ecc8..9d667843bb 100644 --- a/reference/api/search.md +++ b/reference/api/search.md @@ -757,7 +757,7 @@ With the above code sample, Meilisearch will first return documents that contain #### `all` -`all` only returns documents that contain all query terms. Meilisearch will not match any more documents even if there aren't enough to meet the requested `limit`. +`all` only returns documents that contain all query terms. Meilisearch will not match any more documents even if there aren't enough to meet the requested `limit`.