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

Commit edd18a5

Browse files
gmourierbidoubiwabrunoocasaliMarinPostmadichotommy
authored
Settings API - Typo Tolerance (#117)
* Draft file for Typo Tolerance specification * rename spec file * Rename specification * draft * Add open-api.yaml prototype * Add typoTolerance component on POST search * Add typoTolerance object into search api parameters * fix typos * remove the past tense * Add typoTolerance GET query parameters * Fix description * Add explanations for disableOnWords property * Update spec href * Describe indexes/:index_uid/settings/typo-tolerance endpoint * Explain why it is useful to expose typo tolerance settings at search time * Remove typoTolerance properties at search time * Add a future possiblity to change POST verb to PATCH to edit a settings partially * Sync spec with telemetry * Mark TODO on technical details and rework structure of specification * Specify properties required to false to allow partial updates * Add error definitions for typoTolerance API resource properties * Rename spec file * Restore deleted metric * Update text/0117-typo-tolerance-settings-api.md Co-authored-by: cvermand <[email protected]> * Update text/0117-typo-tolerance-settings-api.md Co-authored-by: cvermand <[email protected]> * Apply suggestions from code review Co-authored-by: Bruno Casali <[email protected]> * Replace W to w in telemtry * Apply consistency on new errors message * fix typo * Add Async Errors and Lazy Index Creation * Rename telemetry nodes * Mention case insensivity of disableOnWords parameter * Describes synchronous (type-checking) and asynchronous (business logic) errors * Add examples for minWordSizeFor1Typo and minWordSizeFor2Typos * Elaborate on examples * Remove title bullet point * Apply naming suggestions * Apply naming changes on telemetry and miss on OpenAPI * Branch typo sub-ressource to settings-api specification * Fix typo (lul) * Add Technical Details * Apply suggestions from code review Co-authored-by: cvermand <[email protected]> * Replace minWordSizeForXTypos fields by a minWordSizeForTypos object * Update text/0034-telemetry-policies.md Co-authored-by: ad hoc <[email protected]> * Apply suggestions from code review Co-authored-by: Tommy <[email protected]> * Remove dedicated error for type checking * Update text/0034-telemetry-policies.md Co-authored-by: Bruno Casali <[email protected]> * Bring naming changes * Fix metrics name for typo_tolerance * Update text/0034-telemetry-policies.md Co-authored-by: cvermand <[email protected]> Co-authored-by: Bruno Casali <[email protected]> Co-authored-by: ad hoc <[email protected]> Co-authored-by: Tommy <[email protected]>
1 parent f35ab02 commit edd18a5

File tree

6 files changed

+500
-22
lines changed

6 files changed

+500
-22
lines changed

open-api.yaml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,42 @@ components:
405405
- exactness
406406
- 'release_date:asc'
407407
examples: []
408+
typoTolerance:
409+
type: object
410+
description: Customize typo tolerance feature.
411+
properties:
412+
enabled:
413+
description: Enable the typo tolerance feature.
414+
type: boolean
415+
default: true
416+
nullable: false
417+
disableOnAttributes:
418+
description: Disable the typo tolerance feature on the specified attributes.
419+
type: array
420+
items:
421+
type: string
422+
default: []
423+
nullable: false
424+
disableOnWords:
425+
description: Disable the typo tolerance feature for a set of query terms given for a search query.
426+
type: array
427+
items:
428+
type: string
429+
default: []
430+
nullable: false
431+
minWordSizeForTypos:
432+
type: object
433+
properties:
434+
oneTypo:
435+
description: Customize the minimum size for a word to tolerate 1 typo.
436+
type: integer
437+
default: 5
438+
nullable: false
439+
twoTypos:
440+
description: Customize the minimum size for a word to tolerate 2 typos.
441+
type: integer
442+
default: 9
443+
nullable: false
408444
filterableAttributes:
409445
type: array
410446
description: |
@@ -458,6 +494,8 @@ components:
458494
$ref: '#/components/schemas/searchableAttributes'
459495
displayedAttributes:
460496
$ref: '#/components/schemas/displayedAttributes'
497+
typoTolerance:
498+
$ref: '#/components/schemas/typoTolerance'
461499
required:
462500
- synonyms
463501
- stopWords
@@ -466,6 +504,7 @@ components:
466504
- distinctAttribute
467505
- searchableAttributes
468506
- displayedAttributes
507+
- typoTolerance
469508
stats:
470509
type: object
471510
additionalProperties: false
@@ -1607,6 +1646,8 @@ paths:
16071646
$ref: '#/components/schemas/filterableAttributes'
16081647
sortableAttributes:
16091648
$ref: '#/components/schemas/sortableAttributes'
1649+
typoTolerance:
1650+
$ref: '#/components/schemas/typoTolerance'
16101651
required:
16111652
- rankingRules
16121653
- distinctAttribute
@@ -1616,6 +1657,7 @@ paths:
16161657
- synonyms
16171658
- filterableAttributes
16181659
- sortableAttributes
1660+
- typoTolerance
16191661
examples:
16201662
Example:
16211663
value:
@@ -1657,6 +1699,16 @@ paths:
16571699
- price
16581700
- author
16591701
- title
1702+
typoTolerance:
1703+
enabled: true
1704+
disableOnAttributes:
1705+
- author
1706+
- price
1707+
disableOnWords:
1708+
- Tolkien
1709+
minWordSizeForTypos:
1710+
oneTypo: 4
1711+
twoTypos: 8
16601712
'401':
16611713
$ref: '#/components/responses/401'
16621714
'404':
@@ -1700,6 +1752,8 @@ paths:
17001752
$ref: '#/components/schemas/filterableAttributes'
17011753
sortableAttributes:
17021754
$ref: '#/components/schemas/sortableAttributes'
1755+
typoTolerance:
1756+
$ref: '#/components/schemas/typoTolerance'
17031757
examples:
17041758
Example:
17051759
value:
@@ -1736,6 +1790,16 @@ paths:
17361790
- release_date
17371791
filterableAttributes: []
17381792
sortableAttributes: null
1793+
typoTolerance:
1794+
enabled: false
1795+
disableOnAttributes:
1796+
- title
1797+
- author
1798+
disableOnWords:
1799+
- Tolkien
1800+
minWordSizeForTypos:
1801+
oneTypo: 4
1802+
twoTypos: 8
17391803
responses:
17401804
'202':
17411805
$ref: '#/components/responses/202'
@@ -2054,6 +2118,74 @@ paths:
20542118
description: Not Found
20552119
parameters:
20562120
- $ref: '#/components/parameters/indexUid'
2121+
'/indexes/{indexUid}/settings/typo-tolerance':
2122+
get:
2123+
operationId: indexes.settings.typoTolerance.get
2124+
summary: Get typo tolerance configuration
2125+
description: |
2126+
Get the typo tolerance configuration of an index.
2127+
tags:
2128+
- Settings
2129+
security:
2130+
- apiKey: []
2131+
responses:
2132+
'200':
2133+
description: Ok
2134+
content:
2135+
application/json:
2136+
schema:
2137+
$ref: '#/components/schemas/typoTolerance'
2138+
'401':
2139+
$ref: '#/components/responses/401'
2140+
'404':
2141+
description: Not Found
2142+
post:
2143+
operationId: indexes.settings.typoTolerance.update
2144+
summary: Update typo tolerance settings
2145+
description: |
2146+
Update the typo tolerance configuration of an index.
2147+
2148+
> info
2149+
> If the provided index does not exist, it will be created.
2150+
tags:
2151+
- Settings
2152+
security:
2153+
- apiKey: []
2154+
requestBody:
2155+
required: true
2156+
content:
2157+
application/json:
2158+
schema:
2159+
$ref: '#/components/schemas/typoTolerance'
2160+
examples: {}
2161+
description: ''
2162+
responses:
2163+
'202':
2164+
$ref: '#/components/responses/202'
2165+
'401':
2166+
$ref: '#/components/responses/401'
2167+
'404':
2168+
description: Not Found
2169+
parameters:
2170+
- $ref: '#/components/parameters/Content-Type'
2171+
delete:
2172+
operationId: indexes.settings.typoTolerance.reset
2173+
summary: Reset typo tolerance settings to the default configuration
2174+
description: |
2175+
Reset the typo tolerance settings of an index to its default configuration.
2176+
tags:
2177+
- Settings
2178+
security:
2179+
- apiKey: []
2180+
responses:
2181+
'202':
2182+
$ref: '#/components/responses/202'
2183+
'401':
2184+
$ref: '#/components/responses/401'
2185+
'404':
2186+
description: Not Found
2187+
parameters:
2188+
- $ref: '#/components/parameters/indexUid'
20572189
'/indexes/{indexUid}/settings/filterable-attributes':
20582190
get:
20592191
operationId: indexes.settings.filterableAttributes.get

text/0034-telemetry-policies.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ The collected data is sent to [Segment](https://segment.com/). Segment is a plat
5454
| RankingRules Updated | Occurs when ranking rules are updated via `POST` - `/indexes/:indexUid/settings/ranking-rules`. |
5555
| FilterableAttributes Updated | Occurs when filterable attributes are updated via `POST` - `/indexes/:indexUid/settings/filterable-attributes`. |
5656
| SortableAttributes Updated | Occurs when sortable attributes are updated via `POST` - `/indexes/:indexUid/settings/sortable-attributes`. |
57+
| TypoTolerance Updated | Occurs when typo tolerance settings are updated via `POST` - `/indexes/:indexUid/settings/typo-tolerance`. |
5758
| Dump Created | Occurs when a dump is created via `POST` - `/dumps`. |
5859
| Tasks Seen | Occurs when tasks are fetched globally via `GET` - `/tasks`. |
5960
| Index Tasks Seen | Occurs when tasks are filtered by index via `GET` - `/indexes/:indexUid/tasks`. |
@@ -116,7 +117,12 @@ The collected data is sent to [Segment](https://segment.com/). Segment is a plat
116117
| `sortable_attributes.has_geo` | `true` if `_geo` is set as a sortable attribute, otherwise `false` | true | `Settings Updated`, `SortableAttributes Updated` |
117118
| `filterable_attributes.total` | Number of filterable attributes | 3 | `Settings Updated`, `FilterableAttributes Updated` |
118119
| `filterable_attributes.has_geo` | `true` if `_geo` is set as a filterable attribute, otherwise `false` | false | `Settings Updated`, `FilterableAttributes Updated`|
119-
| `searchable_attributes.total` | Number of searchable attributes | 4 | `Settings Updated`, `SearchableAttributes Update` |
120+
| `searchable_attributes.total` | Number of searchable attributes | 4 | `Settings Updated`, `SearchableAttributes Updated` |
121+
| `typo_tolerance.enabled` | Whether the typo tolerance is enabled | `true` | `Settings Updated`, `TypoTolerance Updated` |
122+
| `typo_tolerance.disable_on_attributes` | `true` if at least one value is defined | `false` | `Settings Updated`, `TypoTolerance Updated` |
123+
| `typo_tolerance.disable_on_words` | `true` if at least one value is defined | `false` | `Settings Updated`, `TypoTolerance Updated` |
124+
| `typo_tolerance.min_word_size_for_typos.one_typo` | The defined value for `minWordSizeForTypos.oneTypo` property | `5` | `Settings Updated`, `TypoTolerance Updated` |
125+
| `typo_tolerance.min_word_size_for_typos.two_typos`| The defined value for `minWordSizeForTypos.twoTypos` property | `9` | `Settings Updated`, `TypoTolerance Updated` |
120126
| `per_task_uid` | `true` if an uid is used to fetch a particular task resource, otherwise `false` | true | `Tasks Seen`, `Index Tasks Seen` |
121127
|
122128

@@ -275,12 +281,18 @@ This property allows us to gather essential information to better understand on
275281
| Property name | Description | Example |
276282
|---------------|-------------|---------|
277283
| user_agent | Represents the user-agent encountered on this call. | `["Meilisearch Ruby (v2.1)", "Ruby (3.0)"]` |
284+
| searchable_attributes.total | Number of searchable attributes. | `3`|
278285
| ranking_rules.sort_position | Position of the `sort` ranking rule if any, otherwise `null`. | `5` |
279286
| sortable_attributes.total | Number of sortable attributes. | `3` |
280287
| sortable_attributes.has_geo | Indicate if `_geo` is set as a sortable attribute. | `false`|
281288
| filterable_attributes.total | Number of filterable attributes. | `3` |
282289
| filterable_attributes.has_geo | Indicate if `_geo` is set as a filterable attribute. | `false`|
283-
| searchable_attributes.total | Number of searchable attributes. | `3`|
290+
| typo_tolerance.enabled | Whether the typo tolerance is enabled. | `true` |
291+
| typo_tolerance.disable_on_attributes | `true` if at least one value is defined for `disableOnAttributes` property. | `false` |
292+
| typo_tolerance.disable_on_words | `true` if at least one value is defined for `disableOnWords` property. | `false` |
293+
| typo_tolerance.min_word_size_for_typos.one_typo | The defined value for `minWordSizeForTypos.oneTypo` property. | `5` |
294+
| typo_tolerance.min_word_size_for_typos.two_typos | The defined value for `minWordSizeForTypos.twoTypos` property. | `9` |
295+
284296
---
285297

286298
## `RankingRules Updated`
@@ -317,6 +329,17 @@ This property allows us to gather essential information to better understand on
317329
| user_agent | Represents the user-agent encountered on this call. | `["Meilisearch Ruby (v2.1)", "Ruby (3.0)"]` |
318330
| searchable_attributes.total | Number of searchable attributes. | `3` |
319331

332+
333+
## `TypoTolerance Updated`
334+
335+
| Property name | Description | Example |
336+
|---------------|-------------|---------|
337+
| typo_tolerance.enabled | Whether the typo tolerance is enable.d | `true` |
338+
| typo_tolerance.disable_on_attributes | `true` if at least one value is defined for `disableOnAttributes` property. | `false` |
339+
| typo_tolerance.disable_on_words | `true` if at least one value is defined for `disableOnWords` property. | `false` |
340+
| typo_tolerance.min_word_size_for_typos.one_typo | The defined value for `minWordSizeForTypos.oneTypo` property. | `5` |
341+
| typo_tolerance.min_word_size_for_typos.two_typos | The defined value for `minWordSizeForTypos.twoTypos` property. | `9` |
342+
320343
## `Dump Created`
321344

322345
| Property name | Description | Example |

text/0061-error-format-and-definitions.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,30 @@ HTTP Code: `400 Bad Request`
222222

223223
---
224224

225+
## invalid_typo_tolerance_min_word_size_for_typos
226+
227+
`Asynchronous`
228+
229+
### Context
230+
231+
This error happens when the `minWordSizeForTypos` object of the `typo` resource is invalid.
232+
233+
### Error Definition
234+
235+
```json
236+
{
237+
"message": "`minWordSizeForTypos` setting is invalid. `oneTypo` and `twoTypos` fields should be between `0` and `255`, and `twoTypos` should be greater or equals to `oneTypo` but found `oneTypo: :oneTypo` and twoTypos: twoTypos`.",
238+
"code": "invalid_typo_tolerance_min_word_size_for_typos",
239+
"type": "invalid_request",
240+
"link": "https://docs.meilisearch.com/errors#invalid_typo_tolerance_min_word_size_for_typos"
241+
}
242+
```
243+
244+
- The `:oneTypo` is inferred when the message is generated.
245+
- The `:twoTypos` is inferred when the message is generated.
246+
247+
---
248+
225249
## index_already_exists
226250

227251
`Asynchronous`

0 commit comments

Comments
 (0)