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

Get ElasticSearch Server now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.