In contrast to searching, analytics deals with the bigger picture. Searching addresses the need for zooming in to a few records, whereas analytics address the need for zooming out and slicing the data in different ways.
While learning about searching, we used the following API:
POST /<index_name>/_search
{
"query":
{
... type of query ...
}
}
All aggregation queries take a common form. Let's go over the structure.
The aggregations, or aggs, element allows us to aggregate data. All aggregation requests take the following form:
POST /<index_name>/_search...
{
"aggs": {
... type of aggregation ...
},
"query": { ... type of query ... }, //optional query part
"size": 0 //size typically set to 0
}