Using the SQL Rest API
X-Pack allows you to bring the power of SQL, the standard language for query data, to Elasticsearch to simplify both the usage of data users and the integration of external applications.
Getting ready
You need an up-and-running Elasticsearch installation, as we described in the Downloading and installing Elasticsearch recipe in Chapter 1, Getting Started.
To execute these commands, any HTTP client can be used, such as curl
(https://curl.haxx.se/), Postman (https://www.getpostman.com/), or similar. I suggest you use the Kibana console, as it provides code completion and better character escaping for Elasticsearch. We will use the datasets that were populated in Chapter 4, Exploring Search Capabilities and Chapter 7, Aggregations.
How to do it…
We will execute the following steps:
- We want to return the first five books ordered by quantity; we will use the following API call:
GET _sql?format=txt { "query": "...