The following code block in regular expression syntax demonstrates the basic structure of the aggregation query syntax:
"aggs":{
"name_1": {
"type": { body }
[,"aggs" : {[sub aggregation]+}]?
}
[,"name_2":{...}]*
}
We can have multiple aggregations in one shot. In addition, if we have to use complex aggregation logic to solve a problem, we may use sub-aggregations. The aggs keyword is the short form of the aggregations keyword. The name_1 word is the name of the aggregation. Elasticsearch supports more than one aggregation on the same level, such as name_2. The type word is used to define the type of the aggregation such as terms, stats, and range. The body word specifies the criteria of the aggregation.
One of the powerful features of aggregations is the ability to embed aggregations...