ES Provides aggregated data based on a search query.
Aggregation Structure:
"aggregations" : {
"<aggregation_name>" : {
"<aggregation_type>" : {
<aggregation_body>
}
[,"meta" : { [<meta_data_body>] } ]?
[,"aggregations" : { [<sub_aggregation>]+ } ]?
}
[,"<aggregation_name_2>" : { ... } ]*
}
#Aggregation_name is a logical name that user defines it.
#aggregation_type is added based on the nature of aggregation. For eg avg_price to calculate average of the price bucket.
GET employees/_search
{
"_source": false,
"query": {
"exists": {
"field": "employee.address"
}
},
"aggs": { // aggregations
"address": {
"terms": {
"field": "employee_name",
"size": 500
}
}
}
}
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-min-aggregation.html
No comments:
Post a Comment