Mapping a completion suggester
In order to provide search functionalities for your user, one of the most common requirements is to provide text suggestions for your query.
ElasticSearch provides a helper to archive this functionality via a special type mapping called completion
.
Getting ready
You need a working ElasticSearch cluster.
How to do it...
The definition of a completion field is similar to that of the previous core type fields. For example, to provide suggestions for a name with an alias, you can write a similar mapping:
{ "name": {"type": "string", "copy_to":["suggest"]}, "alias": {"type": "string", "copy_to":["suggest"]}, "suggest": { "type": "complection", "payloads": true, "index_analyzer": "simple", "search_analyzer": "simple" } }
In this example, we have defined two string fields, name
and alias
, and a suggest
completer for them.
How it works...
There are several ways in which you can provide a suggestion in ElasticSearch. You can have the same functionality...