You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _field-types/supported-field-types/completion.md
+33-2Lines changed: 33 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,37 @@ PUT chess_store
37
37
```
38
38
{% include copy-curl.html %}
39
39
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
+
40
71
Index suggestions into OpenSearch:
41
72
42
73
```json
@@ -313,14 +344,14 @@ GET chess_store/_search
313
344
To use all default fuzziness options, specify `"fuzzy": {}` or `"fuzzy": true`.
314
345
{: .tip}
315
346
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.
317
348
318
349
Parameter | Description
319
350
:--- | :---
320
351
`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`.
321
352
`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.
322
353
`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`.
324
355
`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.
0 commit comments