ELASTICSEARCH Aggregation(Metric)
평균, 합, 최소, 최대 등 산술 분석을 제공
Add Documents
wget https://raw.githubusercontent.com/minsuk-heo/BigData/master/ch03/simple_basketball.json
curl -XPOST localhost:9200/_bulk --data-binary @simple_basketball.json
Average
curl -XGET localhost:9200/_search?pretty --data-binary @avg_points_aggs.json
Get avg_points_aggs.json
wget https://raw.githubusercontent.com/minsuk-heo/BigData/master/ch03/avg_points_aggs.json
{
"size": 0,
"aggs": {
"avg_score": {
"avg": {
"field": "points"
}
}
}
}
Max
curl -XGET localhost:9200/_search?pretty --data-binary @max_points_aggs.json
Get max_points_aggs.json
wget https://raw.githubusercontent.com/minsuk-heo/BigData/master/ch03/max_points_aggs.json
{
"size": 0,
"aggs": {
"max_score": {
"max": {
"field": "points"
}
}
}
}
Min
curl -XGET localhost:9200/_search?pretty --data-binary @min_points_aggs.json
Get min_points_aggs.json
wget https://raw.githubusercontent.com/minsuk-heo/BigData/master/ch03/min_points_aggs.json
{
"size": 0,
"aggs": {
"min_score": {
"min": {
"field": "points"
}
}
}
}
Sum
curl -XGET localhost:9200/_search?pretty --data-binary @sum_points_aggs.json
Get sum_points_aggs.json
wget https://raw.githubusercontent.com/minsuk-heo/BigData/master/ch03/sum_points_aggs.json
{
"size": 0,
"aggs": {
"sum_score": {
"sum": {
"field": "points"
}
}
}
}
Stats
평균, 합, 최소, 최대 한 번에 도출
curl -XGET localhost:9200/_search?pretty --data-binary @stats_points_aggs.json
Get stats_points_aggs.json
wget https://raw.githubusercontent.com/minsuk-heo/BigData/master/ch03/stats_points_aggs.json
{
"size": 0,
"aggs": {
"stats_score": {
"stats": {
"field": "points"
}
}
}
}