Using the nested query
For queries based on nested objects, as we saw in Chapter 2, Managing Mapping, there is a special nested query. This kind of query is required because nested objects are indexed in a special way in Elasticsearch.
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 using the Kibana console, as it provides code completion and better character escaping for querying text.
To correctly execute the following commands, you will need an index populated with the ch04/populate_kibana.txt
commands, which are available in the online code.
The index that's used in this recipe is mybooks-join
.
How to do it...
To execute the nested
query, we will...