Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Search API — Add matchingStrategy parameter with last / all strategies #173

Merged
merged 3 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions open-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,17 @@ components:
type: boolean
default: 'false'
description: Defines whether an `_matchesPosition` object that contains information about the matches should be returned or not.
matchingStrategy:
name: matchingStrategy
in: query
required: false
schema:
type: string
enum:
- last
- all
default: 'last'
description: Defines which strategy to use to match the query terms within the documents as search results. Two different strategies are available, `last` and `all`. By default, the `last` strategy is chosen.
sort:
name: sort
in: query
Expand Down Expand Up @@ -1620,6 +1631,7 @@ paths:
- $ref: '#/components/parameters/sort'
- $ref: '#/components/parameters/limit'
- $ref: '#/components/parameters/showMatchesPosition'
- $ref: '#/components/parameters/matchingStrategy'
responses:
'200':
description: Ok
Expand Down Expand Up @@ -1724,6 +1736,10 @@ paths:
type: boolean
description: Defines whether an `_matchesPosition` object that contains information about the matches should be returned or not.
default: false
matchingStrategy:
type: string
description: Defines which strategy to use to match the query terms within the documents as search results. Two different strategies are available, `last` and `all`. By default, the `last` strategy is chosen.
default: 'last'
filter:
$ref: '#/components/schemas/filter'
facets:
Expand Down Expand Up @@ -1762,6 +1778,7 @@ paths:
attributesToHighlight:
- overview
showMatchesPosition: true
wordsMatchingStrategy: all
responses:
'200':
description: Ok
Expand Down
4 changes: 4 additions & 0 deletions text/0034-telemetry-policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ The collected data is sent to [Segment](https://segment.com/). Segment is a plat
| `filtered_by_type` | `true` if `GET /tasks` endpoint is filered by `type`, otherwise `false` | false | `Tasks Seen` |
| `filtered_by_status` | `true` if `GET /tasks` endpoint is filered by `status`, otherwise `false` | false | `Tasks Seen` |
| `per_index_uid` | `true` if an uid is used to fetch an index stat resource, otherwise `false` | false | `Stats Seen` |
| `most_used_matching_strategy` | Most used word matching strategy among all search requests in this batch | `last` | `Documents Searched POST`, `Documents Searched GET` |

----

#### Detailed list of Instance metrics and, events with their metrics
Expand Down Expand Up @@ -218,6 +220,7 @@ This property allows us to gather essential information to better understand on
| formatting.crop_marker | Does `cropMarker` has been used in the aggregated event? If yes, `true` otherwise `false` | `false` |
| formatting.show_matches_position | Does `showMatchesPosition` has been used in the aggregated event? If yes, `true` otherwise `false` | `false` |
| facets | Does `facets` has been used in the aggregated event? If yes, `true` otherwise `false` | `false` |
| most_used_matching_strategy | Most used word matching strategy among all search requests in the aggregated event. `last` / `all` | `last` |

---

Expand Down Expand Up @@ -246,6 +249,7 @@ This property allows us to gather essential information to better understand on
| formatting.crop_marker | Does `cropMarker` has been used in the aggregated event? If yes, `true` otherwise `false` | `false` |
| formatting.show_matches_position | Does `showMatchesPosition` has been used in the aggregated event? If yes, `true` otherwise `false` | `false` |
| facets | Does `facets` has been used in the aggregated event? If yes, `true` otherwise `false` | `false` |
| most_used_matching_strategy | Most used word matching strategy among all search requests in the aggregated event. `last` / `all` | `last` |

---

Expand Down
80 changes: 50 additions & 30 deletions text/0118-search-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,23 @@ If a master key is used to secure a Meilisearch instance, the auth layer returns

### 3.1. Search Payload Parameters

| Field | Type | Required |
|-------------------------------------------------------|---------------------------|----------|
| [`q`](#311-q) | String | False |
| [`filter`](#312-filter) | Array of String - String | False |
| [`sort`](#313-sort) | Array of String - String | False |
| [`facets`](#314-facets) | Array of String - String | False |
| [`limit`](#315-limit) | Integer | False |
| [`offset`](#316-offset) | Integer | False |
| [`attributesToRetrieve`](#317-attributestoretrieve) | Array of String - String | False |
| [`attributesToHighlight`](#318-attributestohighlight) | Array of String - String | False |
| [`highlightPreTag`](#319-highlightpretag) | String | False |
| [`highlightPostTag`](#3110-highlightposttag) | String | False |
| [`attributesToCrop`](#3111-attributestocrop) | Array of String - String | False |
| [`cropLength`](#3112-croplength) | Integer | False |
| [`cropMarker`](#3113-cropmarker) | String | False |
| [`showMatchesPosition`](#3114-showmatchesposition) | Boolean | False |
| Field | Type | Required |
|-------------------------------------------------------|--------------------------|----------|
| [`q`](#311-q) | String | False |
| [`filter`](#312-filter) | Array of String - String | False |
| [`sort`](#313-sort) | Array of String - String | False |
| [`facets`](#314-facets) | Array of String - String | False |
| [`limit`](#315-limit) | Integer | False |
| [`offset`](#316-offset) | Integer | False |
| [`attributesToRetrieve`](#317-attributestoretrieve) | Array of String - String | False |
| [`attributesToHighlight`](#318-attributestohighlight) | Array of String - String | False |
| [`highlightPreTag`](#319-highlightpretag) | String | False |
| [`highlightPostTag`](#3110-highlightposttag) | String | False |
| [`attributesToCrop`](#3111-attributestocrop) | Array of String - String | False |
| [`cropLength`](#3112-croplength) | Integer | False |
| [`cropMarker`](#3113-cropmarker) | String | False |
| [`showMatchesPosition`](#3114-showmatchesposition) | Boolean | False |
| [`matchingStrategy](#3115-matchingStrategy) | String | False |

#### 3.1.1. `q`

Expand Down Expand Up @@ -647,18 +648,37 @@ It's useful when more control is needed than offered by the built-in highlightin

- 🔴 Sending a value with a different type than `Boolean` or `null` for `showMatchesPosition` returns a [bad_request](0061-error-format-and-definitions.md#bad_request) error.

#### 3.1.15. `matchingStrategy`

- Type: String
- Required: False
- Default: `last`

Defines which strategy to use to match the query terms within the documents as search results.

Two different strategies are available, `last` and `all`. By default, the `last` strategy is chosen.

- 🔴 Sending a value with a different type than `String` and other than `last` or `all` as a value for `matchingStrategy` returns a [bad_request](0061-error-format-and-definitions.md#bad_request) error.

##### 3.1.15.1. `last` strategy

The documents containing ALL the query words (i.e. in the `q` parameter) are returned first by Meilisearch. If Meilisearch doesn't have enough documents to fit the requested `limit`, it iteratively ignores the query words from the last typed word to the first typed word to match more documents.

##### 3.1.15.2. `all` strategy

Only the documents containing ALL the query words (i.e. in the `q` parameter) are returned by Meilisearch. If Meilisearch doesn't have enough documents to fit the requested `limit`, it returns the documents found without trying to match more documents.

### 3.2. Search Response Properties

| Field | Type | Required |
|-------------------------------------------------------|------------------------------|----------|
| [`hits`](#321-hits) | Array[Hit] | True |
| [`limit`](#322-limit) | Integer | True |
| [`offset`](#323-offset) | Integer | True |
| [`estimatedTotalHits`](#324-estimatedTotalHits) | Integer | True |
| [`facetDistribution`](#325-facetdistribution) | Object | False |
| [`processingTimeMs`](#326-processingtimems) | Integer | True |
| [`query`](#327-query) | String | True |
| Field | Type | Required |
|-------------------------------------------------|------------|----------|
| [`hits`](#321-hits) | Array[Hit] | True |
| [`limit`](#322-limit) | Integer | True |
| [`offset`](#323-offset) | Integer | True |
| [`estimatedTotalHits`](#324-estimatedTotalHits) | Integer | True |
| [`facetDistribution`](#325-facetdistribution) | Object | False |
| [`processingTimeMs`](#326-processingtimems) | Integer | True |
| [`query`](#327-query) | String | True |

#### 3.2.1. `hits`

Expand All @@ -675,11 +695,11 @@ A search result can contain special properties. See [3.2.1.1. `hit` Special Prop

##### 3.2.1.1. `hit` Special Properties

| Field | Type | Required |
|--------------------------------------|-------------|----------|
| [`_geoDistance`](#32111-geodistance) | Integer | False |
| [`_formatted`](#32112-formatted) | Object | False |
| [`_matchesPosition`](#32113-matchesposition) | Object | False |
| Field | Type | Required |
|----------------------------------------------|---------|----------|
| [`_geoDistance`](#32111-geodistance) | Integer | False |
| [`_formatted`](#32112-formatted) | Object | False |
| [`_matchesPosition`](#32113-matchesposition) | Object | False |

###### 3.2.1.1.1. `_geoDistance`

Expand Down