데이터 엔지니어링/AWS
[ELK] Elastic Search (3)
데이터길드장
2023. 11. 11. 16:52
Metric Aggregation
산술 aggregation
{
"size" : 0,
"aggs" : {
"stats_score" : {
"stats" : {
"field" : "points"
}
}
}
}
curl -XGET -H'Content-Type: application/json' localhost:9200/_search?pretty --data-binary @avg_points_aggs.json
- AVG(평균)
- MAX (최대값)
- status : count/ min / max / avg / sum => aggregation이 다 나올 수 있는 코드
Bucket aggregation
SQL Group by와 같음
{
"size" : 0,
"aggs" : {
"team_stats" : {
"terms" : {
"field" : "team"
},
"aggs" : {
"stats_score" : {
"stats" : {
"field" : "points"
}
}
}
}
}
}
- 일단 index 생성 후 mapping
curl -XPUT 'http://localhost:9200/basket/record/_mapping?include_type_name=true' -H "Content-Type: application/json" -d @basketball_mapping.json
- document @file로 post하기
curl -XPOST 'localhost:9200/\_bulk' -H 'Content-Type: application/json' --data-binary @twoteam\_basketball.json
- bucket aggregation search
curl -XGET -H "Content-Type: application/json" localhost:9200/basket/\_search?pretty --data-binary
@terms\_aggs.json
team별로 document를 묶은 다음 결과값에서 또 aggregation을 진행함
index 조회
curl -XGET 'localhost:9200/\_cat/indices?v'
index 삭제
curl --location --request DELETE 'localhost:9200/basketbal'
[Elasticsearch] 기본 개념잡기
1. Elasticsearch란?Elasticsearch는 Apache Lucene( 아파치 루씬 ) 기반의 Java 오픈소스 분산 검색 엔진입니다.Elasticsearch를 통해 루씬 라이브러리를 단독으로 사용할 수 있게 되었으며, 방대한 양의 데이터를
victorydntmd.tistory.com
반응형