Suggesting a correct query
It's very common for users to commit typing errors or to require suggestions for words that they are writing. These issues are solved by Elasticsearch with the suggest functionality.
Getting ready
You will need an up-and-running Elasticsearch installation as used in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
To execute curl
via a command line, you need to install curl
for your operating system.
To correctly execute the following commands, you will need an index populated with the chapter_05/populate_query.sh
script available in the online code.
How to do it...
To suggest relevant terms by query, we will perform the following steps:
From the command line, we can execute a suggest call, as follows:
curl -XGET 'http://127.0.0.1:9200/test-index/_suggest? pretty' -d '{ "suggest1" : { "text" : "we find tester", "term" : { "field" : "parsedtext...