- Elasticsearch 7.0 Cookbook(Fourth Edition)
- Alberto Paro
- 83字
- 2021-06-24 14:52:14
How to do it...
The definition of a completion field is similar to the previous core type fields. For example, to provide a suggestion for a name with an alias, we can write a similar mapping similar to the following:
{
"name": {"type": "string", "copy_to":["suggest"]},
"alias": {"type": "string", "copy_to":["suggest"]},
"suggest": {
"type": "completion",
"payloads": true,
"analyzer": "simple",
"search_analyzer": "simple"
}
}
In this example, we have defined two string fields: name and alias, as well as a suggest completer for them.