Skip to content

Commit

Permalink
v1.4: New dictionary index setting (#2551)
Browse files Browse the repository at this point in the history
* add new `dictionary` index setting

* polish wording

* improve wording
  • Loading branch information
guimachiavelli authored Sep 14, 2023
1 parent 705afb1 commit 30037b5
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1120,3 +1120,17 @@ search_parameter_guide_attributes_to_search_on_1: |-
"q": "adventure",
"attributesToSearchOn": ["overview"]
}'
get_dictionary_1: |-
curl \
-X GET 'http://localhost:7700/indexes/books/settings/dictionary'
update_dictionary_1: |-
curl \
-X PUT 'http://localhost:7700/indexes/books/settings/dictionary' \
-H 'Content-Type: application/json' \
--data-binary '[
"J. R. R.",
"W. E. B."
]'
reset_dictionary_1: |-
curl \
-X DELETE 'http://localhost:7700/indexes/books/settings/dictionary'
1 change: 1 addition & 0 deletions learn/what_is_meilisearch/telemetry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ This list is liable to change with every new version of Meilisearch. It's not be
| `displayed_attributes.total` | Number of displayed attributes | 3
| `displayed_attributes.with_wildcard` | `true` if `*` is specified as a displayed attribute, otherwise `false` | false
| `stop_words.total` | Number of stop words | 3
| `dictionary.total` | Number of words in the dictionary | 3
| `synonyms.total` | Number of synonyms | 3
| `per_index_uid` | `true` if the `uid` is used to fetch an index stat resource, otherwise `false` | false
| `searches.avg_search_count` | The average number of search queries received per call for the aggregated event | 4.2
Expand Down
113 changes: 112 additions & 1 deletion reference/api/settings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ By default, the settings object looks like this. All fields are modifiable.
"exactness"
],
"stopWords": [],
"dictionary": [],
"synonyms": {},
"distinctAttribute": null,
"typoTolerance": {
Expand Down Expand Up @@ -94,6 +95,7 @@ Get the settings of an index.
"exactness"
],
"stopWords": [],
"dictionary": [],
"synonyms": {},
"distinctAttribute": null,
"typoTolerance": {
Expand Down Expand Up @@ -136,12 +138,13 @@ If the provided index does not exist, it will be created.

| Name | Type | Default value | Description |
| :--------------------------------------------------- | :--------------- | :----------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------- |
| **[`dictionary`](#dictionary)** | Array of strings | Empty | List of strings Meilisearch should parse as a single term |
| **[`displayedAttributes`](#displayed-attributes)** | Array of strings | All attributes: `["*"]` | Fields displayed in the returned documents |
| **[`distinctAttribute`](#distinct-attribute)** | String | `null` | Search returns documents with distinct (different) values of the given field |
| **[`faceting`](#faceting)** | Object | [Default object](#faceting-object) | Faceting settings |
| **[`filterableAttributes`](#filterable-attributes)** | Array of strings | Empty | Attributes to use as filters and facets |
| **[`pagination`](#pagination)** | Object | [Default object](#pagination-object) | Pagination settings |
| **[`rankingRules`](#ranking-rules)** | Array of strings | `["words",`<br />`"typo",`<br />`"proximity",`<br />`"attribute",`<br />`"sort",`<br />`"exactness"]` | List of ranking rules in order of importance |
| **[`rankingRules`](#ranking-rules)** | Array of strings | `["words",`<br />`"typo",`<br />`"proximity",`<br />`"attribute",`<br />`"sort",`<br />`"exactness"]` | List of ranking rules in order of importance |
| **[`searchableAttributes`](#searchable-attributes)** | Array of strings | All attributes: `["*"]` | Fields in which to search for matching query words sorted by order of importance |
| **[`sortableAttributes`](#sortable-attributes)** | Array of strings | Empty | Attributes to use when sorting search results |
| **[`stopWords`](#stop-words)** | Array of strings | Empty | List of words ignored by Meilisearch when present in search queries |
Expand Down Expand Up @@ -200,6 +203,114 @@ Reset all the settings of an index to their [default value](#settings-object).

You can use this `taskUid` to get more details on [the status of the task](/reference/api/tasks#get-one-task).

## Dictionary

Allows users to instruct Meilisearch to consider groups of strings as a single term by adding a supplementary dictionary of user-defined terms.

This is particularly useful when working with datasets containing many domain-specific words, and in languages where words are not separated by whitespace such as Japanese.

Custom dictionaries are also useful in a few use-cases for space-separated languages, such as datasets with names such as `"J. R. R. Tolkien"` and `"W. E. B. Du Bois"`.

<Capsule intent="tip">
User-defined dictionaries can be used together with synonyms. It can be useful to configure Meilisearch so different spellings of an author's initials return the same results:

```json
"dictionary": ["W. E. B.", "W.E.B."],
"synonyms": {
"W. E. B.": ["W.E.B."],
"W.E.B.": ["W. E. B."]
}
```
</Capsule>

### Get dictionary

<RouteHighlighter method="GET" route="/indexes/{index_uid}/settings/dictionary"/>

Get an index's user-defined dictionary.

#### Path parameters

| Name | Type | Description |
| :---------------- | :----- | :------------------------------------------------------------------------ |
| **`index_uid`** * | String | [`uid`](/learn/core_concepts/indexes#index-uid) of the requested index |

#### Example

<CodeSamples id="get_dictionary_1" />

##### Response: `200 OK`

```json
[]
```

### Update dictionary

<RouteHighlighter method="PUT" route="/indexes/{index_uid}/settings/dictionary"/>

Update an index's user-defined dictionary.

#### Path parameters

| Name | Type | Description |
| :---------------- | :----- | :------------------------------------------------------------------------ |
| **`index_uid`** * | String | [`uid`](/learn/core_concepts/indexes#index-uid) of the requested index |

#### Body

```json
["J. R. R.", "W. E. B."]
```

#### Example

<CodeSamples id="update_dictionary_1" />

##### Response: `202 Accepted`

```json
{
"taskUid": 1,
"indexUid": "books",
"status": "enqueued",
"type": "settingsUpdate",
"enqueuedAt": "2023-09-11T15:39:06.073314Z"
}
```

Use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks#get-one-task).

### Reset dictionary

<RouteHighlighter method="DELETE" route="/indexes/{index_uid}/settings/dictionary"/>

Reset an index's dictionary to its default value, `[]`.

#### Path parameters

| Name | Type | Description |
| :---------------- | :----- | :------------------------------------------------------------------------ |
| **`index_uid`** * | String | [`uid`](/learn/core_concepts/indexes#index-uid) of the requested index |

#### Example

<CodeSamples id="reset_dictionary_1" />

##### Response: `202 Accepted`

```json
{
"taskUid": 1,
"indexUid": "books",
"status": "enqueued",
"type": "settingsUpdate",
"enqueuedAt": "2022-04-14T20:53:32.863107Z"
}
```

Use the returned `taskUid` to get more details on [the status of the task](/reference/api/tasks#get-one-task).

## Displayed attributes

The attributes added to the `displayedAttributes` list appear in search results. `displayedAttributes` only affects the search endpoints. It has no impact on the [get documents with POST](/reference/api/documents#get-documents-with-post) and [get documents with GET](/reference/api/documents#get-documents-with-get) endpoints.
Expand Down

0 comments on commit 30037b5

Please sign in to comment.