The basics of aggregations
In contrast to search, analytics deals with the bigger picture. Searching addresses the need for zooming in to a few records; analytics addresses the need for zooming out and slicing the data in different ways. While learning about searching, we used the API of the following form:
POST /<index_name>/<type_name>/_search { "query": { ... type of query ... } }
All aggregation queries take a common form. Let us understand the structure.
The aggregations or aggs
element allows us to aggregate data. All aggregation requests take the following form:
POST /<index_name>/<type_name>/_search { "aggs": { ... type of aggregation ... }, "query": { ... type of query ... }, //optional query part "size": 0 //size typically set to 0 }
The aggs
element should contain the actual aggregation query. The body depends on the type of aggregation that...