Skip to content

Commit abe151a

Browse files
Add mapping parameters to completion fields (#10295) (#10304)
1 parent cd576a1 commit abe151a

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

_field-types/supported-field-types/completion.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,37 @@ PUT chess_store
3737
```
3838
{% include copy-curl.html %}
3939

40+
## Mapping parameters
41+
42+
The `completion` field type supports the following mapping parameters.
43+
44+
| Parameter | Description |
45+
| :--- | :--- |
46+
| `analyzer` | Specifies the index-time analyzer for input text. Default is `simple`. See [Index analyzers]({{site.url}}{{site.baseurl}}/analyzers/index-analyzers/). |
47+
| `search_analyzer` | Defines the analyzer used at search time. Default is the value of `analyzer`. See [Search analyzers]({{site.url}}{{site.baseurl}}/analyzers/search-analyzers/). |
48+
| `preserve_separators` | If `true` (default), preserves separators such as spaces or punctuation. If set to `false`, allows queries like `queensg` to match a suggestion like "Queen's Gambit". |
49+
| `preserve_position_increments` | If `true` (default), maintains position increments for analyzed tokens. Setting this to `false` can match suggestions like "The Sicilian Defense" when typing `s` because it skips over stopwords like "The". Alternatively, you can index both "Sicilian Defense" and "The Sicilian Defense" as separate inputs without changing the analyzer. |
50+
| `max_input_length` | Limits the length of each input string. Default is `50` UTF-16 code points. This applies only at index time to prevent large inputs from bloating the underlying data structure. Most prefix completions work well within this limit. |
51+
52+
### Example mapping
53+
54+
```json
55+
PUT chess_store
56+
{
57+
"mappings": {
58+
"properties": {
59+
"suggestions": {
60+
"type": "completion",
61+
"analyzer": "standard"
62+
},
63+
"product": {
64+
"type": "keyword"
65+
}
66+
}
67+
}
68+
}
69+
```
70+
4071
Index suggestions into OpenSearch:
4172

4273
```json
@@ -313,14 +344,14 @@ GET chess_store/_search
313344
To use all default fuzziness options, specify `"fuzzy": {}` or `"fuzzy": true`.
314345
{: .tip}
315346

316-
The following table lists the parameters accepted by the fuzzy completion suggester query. All of the parameters are optional.
347+
The following table lists the parameters accepted by the `fuzzy` completion suggester query. All of the parameters are optional.
317348

318349
Parameter | Description
319350
:--- | :---
320351
`fuzziness` | Fuzziness can be set as one of the following: <br> 1. An integer that specifies the maximum allowed [Damerau–Levenshtein distance](https://en.wikipedia.org/wiki/Damerau–Levenshtein_distance) for this edit. <br> 2. `AUTO`: Strings of 0–2 characters must match exactly, strings of 3–5 characters allow 1 edit, and strings longer than 5 characters allow 2 edits.<br> Default is `AUTO`.
321352
`min_length` | An integer that specifies the minimum length the input must be to start returning suggestions. If the search term is shorter than `min_length`, no suggestions are returned. Default is 3.
322353
`prefix_length` | An integer that specifies the minimum length the matched prefix must be to start returning suggestions. If the prefix of `prefix_length` is not matched, but the search term is still within the Damerau–Levenshtein distance, no suggestions are returned. Default is 1.
323-
`transpositions` | A Boolean value that specifies to count transpositions (interchanges of adjacent characters) as one edit instead of two. Example: The suggestion's `input` parameter is `abcde` and the `fuzziness` is 1. If `transpositions` is set to `true`, `abdce` will match, but if `transpositions` is set to `false`, `abdce` will not match. Default is `true`.
354+
`transpositions` | A Boolean value that specifies to count transpositions (interchanges of adjacent characters) as one edit instead of two. Example: The suggestion's `input` parameter is `abcde` and the `fuzziness` is 1. If `transpositions` is set to `true`, `abdce` will match, but if `transpositions` is set to `false`, `abdce` will not match. Default is `true`.
324355
`unicode_aware` | A Boolean value that specifies whether to use Unicode code points when measuring the edit distance, transposition, and length. If `unicode_aware` is set to `true`, the measurement is slower. Default is `false`, in which case distances are measured in bytes.
325356

326357
## Regex queries

0 commit comments

Comments
 (0)