chapter two

2 Getting started

 

This chapter covers

  • Indexing sample documents with Elasticsearch
  • Retrieving, deleting, and updating documents
  • Searching with basic to advanced queries
  • Running aggregations on data

This chapter is all about experiencing a taste of Elasticsearch. Elasticsearch is a Java binary that is available to download from the Elastic company’s website. Once the server is installed and up and running, we will need to plug in our business data so the engine can analyze that data and persist. Once the engine is primed with this data, we can execute search queries to fetch results.

Although any client capable of invoking REST calls can talk to Elasticsearch, we’ll use Kibana as our preferred client throughout this book. Kibana is a web application from the same company that developed Elasticsearch. It is an opulent visual editor that comes with all the bells and whistles, not simply searching for data. With Kibana you get abundant capabilities such as advanced analytical and statistical functions, rich visualizations and dashboards, machine learning models, and more. As Elasticsearch exposes all its functionality via RESTful APIs, we can construct our queries using these APIs in Kibana editor and communicate with the server over HTTP.

2.1 Priming with data

2.1.1 An online bookstore

2.1.2 Indexing documents

2.1.3 Document APIs

2.1.4 Using cURL

2.1.5 Indexing our first document

2.1.6 Constituents of the request

2.1.7 Indexing more documents

2.2 Retrieving Data

2.2.1 Counting all documents

2.2.2 Retrieving documents

2.2.3 Full text queries

2.2.4 Indexing more documents using the _bulk API

2.2.5 Searching across multiple fields

2.2.6 Search on a phrase

2.2.7 Fuzzy queries

2.2.8 Term-level queries

2.3 Compound queries

2.3.1 Boolean (bool) query

2.3.2 The must (must) clause

2.3.3 The must not (must_not) clause

2.3.4 The should (should) clause

2.3.5 The filter (filter) clause