Basic queries

Elasticsearch has extensive search and data analysis capabilities that are exposed in forms of different queries, filters, aggregates, and so on. In this section, we will concentrate on the basic queries provided by Elasticsearch. By basic queries we mean the ones that don't combine the other queries together but run on their own.

The term query

The term query is one of the simplest queries in Elasticsearch. It just matches the document that has a term in a given field - the exact, not analyzed term. 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. Remember that the term query is not analyzed, so you need to provide the exact ...

Get Elasticsearch Server - Third Edition 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.