Using a simple query string query
Typically, the programmer has the control on building complex query using Boolean query and the other query types. Thus, Elasticsearch provides two kinds of queries that give the user the ability to create string queries with several operators in it.
These kinds of queries are very common on advanced search engine usage such as Google that allows to use +
and -
operators on terms.
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
To execute curl
via the command line, you need to install curl
for your operative system.
To correctly execute the following commands, you need an index populated with the chapter_05/populate_query.sh
script available in online code.
How to do it...
For executing a simple query string query, we will perform the following steps:
We want to search for text
nice guy
, but not excluding the termnot
. The query will be...