데이터 처리/ELK
[Elastic Search] Bulk Post
부리부리부리부리
2022. 12. 6. 18:50
저번까진 postman을 사용하여 강의를 따라갔었다. 그런데 Git Bash를 사용하면 윈도우에서도 Linux 명령어를 사용할 수가 있다고 해서 이제부턴 Git Bash로 강의를 진행한다. ( 나이스요 )
이번 내용은 Bulk Post인데, 여러 개의 document를 한 번에 ES에 삽입하는 방법이다.
명령어는 다음과 같다.
curl -XPOST http://localhost:9200/_bulk?pretty --header 'content-type: application/json' --data-binary @classes.json
위 명령어를 보면 header를 같이 인자로 전송해주었는데, ES 6.0 버전 이상부턴 헤더를 같이 보내야한다고 한다.
이제 결과를 확인해보자.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0{
"took" : 159,
"errors" : false,
"items" : [
{
"index" : {
"_index" : "classes",
"_type" : "class",
"_id" : "1",
"_version" : 4,
"result" : "updated",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 5,
"_primary_term" : 2,
"status" : 200
}
},
{
"index" : {
"_index" : "classes",
"_type" : "class",
"_id" : "2",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 6,
"_primary_term" : 2,
"status" : 201
}
},
...
(이하 생략)
다시 한번 잘 들어갔는지 XGET으로 확인해보자.
curl -XGET localhost:9200/classes/class/23pretty
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 67 100 67 0 0 18836 0 --:--:-- --:--:-- --:--:-- 22333{"_index":"classes","_type":"class","_id":"23pretty","found":false}
사실 ELK에 대해 아는거 없이 그냥 시작했는데, 지금까지 느낀 점은 Elastic Search는 ELK 중 DB역할을 하는거같은데?
아직 제대로 써보지 않아서 "와 빠르다!" 라는 느낌은 들지 않는다.