Basic queries
So, we now know what an ElasticSearch query is, how to construct it, and finally, how to send it using an HTTP request. What we don't know yet is what kind of queries ElasticSearch exposes, and thus, what we can use in order to achieve the desired results. In the next few pages of this chapter, we will try to learn which basic queries ElasticSearch allows us to use and what we can do with them.
The term query
The term query is one of the simplest queries in ElasticSearch and just matches any document that has a term in a given field. You are familiar with this query type because we used it already, but just to have all the query types in one place. The simplest term query is as follows:
{ "query" : { "term" : { "title" : "crime" } } }
It will match the documents that have the term "crime" in the title
field. Please remember that the term query is not analyzed, so you need to provide the exact term that will match the term in the indexed document. However, you can also...