Executing nested aggregation
Nested aggregations allow us to execute analysis on nested documents. When working with complex structures, nested objects are very common.
Getting ready
You need a working ElasticSearch cluster and an index populated with the script available at https://github.com/aparo/elasticsearch-cookbook-second-edition.
How to do it...
To execute nested aggregations, we will perform the steps given as follows:
- We must index documents with a nested type, as discussed in the Managing nested objects recipe in Chapter 3, Managing Mapping:
{ "product" : { "properties" : { "resellers" : { "type" : "nested" "properties" : { "username" : { "type" : "string", "index" : "not_analyzed" }, "price" : { "type" : "double" } } }, "tags" : { "type" : "string"...