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"
                  ]
               }
            }
         ]
      }
   ]
}

As you can see, the document about Andrei Tarkovsky has been ...

Get Elasticsearch Indexing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.