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

User dictionary settings API #255

Merged
merged 8 commits into from
Sep 25, 2023
Merged

Conversation

ManyTheFish
Copy link
Member

@ManyTheFish ManyTheFish commented Jul 19, 2023

Summary

Allows the user to provide a custom word dictionary in order to enhance the segmentation of specific words.


Changes

  • add a dedicated settings file
  • update global settings file
  • update telemetry file

Misc

  • Update OpenAPI specification file
  • Update telemetry datapoints

meili-bors bot added a commit to meilisearch/meilisearch that referenced this pull request Aug 10, 2023
3946: Settings customizing tokenization r=irevoire a=ManyTheFish

# Pull Request
This pull Request allows the User to customize Meilisearch Tokenization by providing specialized settings.

## Small documentation
All the new settings can be set and reset like the other index settings by calling the route `/indexes/:name/settings`

### `nonSeparatorTokens`
The Meilisearch word segmentation uses a default list of separators to segment words, however, for specific use cases some of the default separators shouldn't be considered separators, the `nonSeparatorTokens` setting allows to remove of some tokens from the default list of separators.

***Request payload `PUT`- `/indexes/articles/settings/non-separator-tokens`***
```json
["`@",` "#", "&"]
```

### `separatorTokens`
Some use cases need to define additional separators, some are related to a specific way of parsing technical documents some others are related to encodings in documents,  the `separatorTokens` setting allows adding some tokens to the list of separators.

***Request payload `PUT`- `/indexes/articles/settings/separator-tokens`***
```json
["§", "&sep"]
```

### `dictionary`
The Meilisearch word segmentation relies on separators and language-based word-dictionaries to segment words, however, this segmentation is inaccurate on technical or use-case specific vocabulary (like `G/Box` to say `Gear Box`), or on proper nouns (like `J. R. R.` when parsing `J. R. R. Tolkien`), the `dictionary` setting allows defining a list of words that would be segmented as described in the list.

***Request payload `PUT`- `/indexes/articles/settings/dictionary`***
```json
["J. R. R.", "J.R.R."]
```

these last feature synergies well with the `stopWords` setting or the `synonyms` setting allowing to segment words and correctly retrieve the synonyms:
***Request payload `PATCH`- `/indexes/articles/settings`***
```json
{
    "dictionary": ["J. R. R.", "J.R.R."],
    "synonyms": {
            "J.R.R.": ["jrr", "J. R. R."],
            "J. R. R.": ["jrr", "J.R.R."],
            "jrr": ["J.R.R.", "J. R. R."],
    }
}
```

### Related specifications:
- meilisearch/specifications#255
- meilisearch/specifications#254

### Try it with Docker

```bash
$ docker pull getmeili/meilisearch:prototype-tokenizer-customization-3
```

## Related issue
Fixes #3610
Fixes #3917
Fixes https://github.com/meilisearch/product/discussions/468
Fixes https://github.com/meilisearch/product/discussions/160
Fixes https://github.com/meilisearch/product/discussions/260
Fixes https://github.com/meilisearch/product/discussions/381
Fixes https://github.com/meilisearch/product/discussions/131
Related to #2879

Fixes #2760

## What does this PR do?
- Add a setting `nonSeparatorTokens` allowing to remove a token from the default separator tokens
- Add a setting `separatorTokens` allowing to add a token in the separator tokens
- Add a setting `dictionary` allowing to override the segmentation on specific words
- add new error code `invalid_settings_non_separator_tokens` (invalid_request)
- add new error code `invalid_settings_separator_tokens` (invalid_request)
- add new error code `invalid_settings_dictionary` (invalid_request)

Co-authored-by: ManyTheFish <many@meilisearch.com>
Co-authored-by: Many the fish <many@meilisearch.com>
@ManyTheFish ManyTheFish marked this pull request as ready for review September 7, 2023 08:48
macraig
macraig previously approved these changes Sep 20, 2023
text/0123-user-dictionary-settings-api.md Outdated Show resolved Hide resolved
text/0123-user-dictionary-settings-api.md Outdated Show resolved Hide resolved
ManyTheFish and others added 2 commits September 20, 2023 13:13
Co-authored-by: Maria Craig <marycraig90@gmail.com>
Co-authored-by: Maria Craig <marycraig90@gmail.com>
@ManyTheFish ManyTheFish changed the base branch from main to release-v1.4.0 September 25, 2023 11:52
@macraig macraig merged commit 95992aa into release-v1.4.0 Sep 25, 2023
2 checks passed
@macraig macraig deleted the user-dictionary-settings-api branch September 25, 2023 13:59
macraig added a commit that referenced this pull request Sep 25, 2023
* Bump API version

* User dictionary settings API (#255)

* Create 0123-user-dictionary-settings-api.md

* Update 0123-user-dictionary-settings-api.md

* rename wordDictionary into dictionary

* Update 0034-telemetry-policies.md

* Update 0123-settings-api.md

* Update open-api.yaml

* Update text/0123-user-dictionary-settings-api.md

Co-authored-by: Maria Craig <marycraig90@gmail.com>

* Update text/0123-user-dictionary-settings-api.md

Co-authored-by: Maria Craig <marycraig90@gmail.com>

---------

Co-authored-by: Maria Craig <marycraig90@gmail.com>

* Separators settings api (#254)

* Create 0123-separators-settings-api.md

* Update 0123-settings-api.md

* Update 0034-telemetry-policies.md

* Update text/0034-telemetry-policies.md

Co-authored-by: Maria Craig <marycraig90@gmail.com>

* Update text/0034-telemetry-policies.md

Co-authored-by: Maria Craig <marycraig90@gmail.com>

* Update text/0123-separators-settings-api.md

Co-authored-by: cvermand <33010418+bidoubiwa@users.noreply.github.com>

* Update open-api.yaml

* Update text/0123-separators-settings-api.md

---------

Co-authored-by: Maria Craig <marycraig90@gmail.com>
Co-authored-by: cvermand <33010418+bidoubiwa@users.noreply.github.com>

---------

Co-authored-by: María <maria@Marias-MacBook-Pro.local>
Co-authored-by: Many the fish <legendre.maxime.isn@gmail.com>
Co-authored-by: cvermand <33010418+bidoubiwa@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
OpenAPI Update OpenAPI specification. Telemetry Update the telemetry collect.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants