Searching—​The Basic Toolsedit

So far, we have learned how to use Elasticsearch as a simple NoSQL-style distributed document store. We can throw JSON documents at Elasticsearch and retrieve each one by ID. But the real power of Elasticsearch lies in its ability to make sense out of chaos — to turn Big Data into Big Information.

This is the reason that we use structured JSON documents, rather than amorphous blobs of data. Elasticsearch not only stores the document, but also indexes the content of the document in order to make it searchable.

Every field in a document is indexed and can be queried. And it’s not just that. During a single query, Elasticsearch can use all of these indices, to return results at breath-taking speed. That’s something that you could never consider doing with a traditional database.

A search can be any of the following:

  • A structured query on concrete fields like gender or age, sorted by a field like join_date, similar to the type of query that you could construct in SQL
  • A full-text query, which finds all documents matching the search keywords, and returns them sorted by relevance
  • A combination of the two

While many searches will just work out of the box, to use Elasticsearch to its full potential, you need to understand three subjects:

Mapping
How the data in each field is interpreted
Analysis
How full text is processed to make it searchable
Query DSL
The flexible, powerful query language used by Elasticsearch

Each of these is a big subject in its own right, and we explain them in detail in Search in Depth. The chapters in this section introduce the basic concepts of all three—​just enough to help you to get an overall understanding of how search works.

We will start by explaining the search API in its simplest form.