Get suggestions
If we would like to find documents that have directors starting with tar
, we would run the following command:
curl -XGET localhost:9200/imdb/_suggest?pretty -d '{ "directorAutocomplete": { "text": "tar", "completion": { "field": "completion_suggest" } } }'
The result returned by Elasticsearch for the preceding query looks as follows:
{ "_shards": { "total": 5, "successful": 5, "failed": 0 }, "directorAutocomplete": [ { "text": "tar", "offset": 0, "length": 3, "options": [ { "text": "Andrei Arsenyevich Tarkovsky", "score": 1, "payload": { "movies": [ "Ivan's Childhood", "Andrei Rublev", "Solaris", "The Mirror", "Stalker", "Nostalgia", "The Sacrifice" ] ...