61
62

More than 5 years have passed since last update.

elasticsearchでjsonをimportする(高速)

Last updated at Posted at 2014-01-08

jsonを作成する

requests.json
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{ "field1" : "value2" }

bulk importする

curl -s -XPOST localhost:9200/_bulk --data-binary @requests.json > /dev/null

標準出力からも可

curl -s -XPOST localhost:9200/_bulk --data-binary @<(head -n 2 requests.json) > /dev/null

gzip圧縮されたファイルでbulk importする

elasticsearch.ymlに追記

elasticsearch.yml
http.compression: true

インポート

curl --compressed -H "Content-encoding: gzip" -XPOST localhost:9200/_bulk --data-binary @requests.json.gz > /dev/null
61
62
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
61
62