Elasticsearch bulk insert

By | 2020년 7월 5일
Table of Contents

Elasticsearch bulk insert

데이타 파일 생성

인덱스가 이미 있는 경우 삭제해 줍니다.

curl -XDELETE http://localhost:9200/auto_complete?pretty -H 'Content-Type: application/json'

데이타 파일을 생성합니다.

vi data.json
{ "index":{ "_index" : "auto_complete", "_type" : "_doc" } }
{ "search_string":"셀프빨래방"}
{ "index":{ "_index" : "auto_complete", "_type" : "_doc" } }
{ "search_string":"빨래건조대"}
{ "index":{ "_index" : "auto_complete", "_type" : "_doc" } }
{ "search_string":"볼빨간사춘기"}
{ "index":{ "_index" : "auto_complete", "_type" : "_doc" } }
{ "search_string":"빨래건조기"}

데이타 입력

curl -XPOST http://localhost:9200/_bulk?pretty -H 'Content-Type: application/json' --data-binary @data.json

데이타 확인

curl -XPOST 'localhost:9200/auto_complete/_search?pretty' -H 'Content-Type: application/json' -d'{
  "query": {
      "match_all": {}
  }
}'

답글 남기기