0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Elasticsearch bulkを使って複数ドキュメント登録

Posted at

Elasticsearchで一つ一つドキュメントを追加していくのが面倒だったため、jsonファイルを使って複数ドキュメントを追加していきます。

JSONファイル

sample.json
{"index":{}}
{"id": 1, "name": "じゃがりこ"}
{"index":{}}
{"id": 2, "name": "マイクポップコーン"}
{"index":{}}
{"id": 3, "name": "チョコあ〜んぱん"}
{"index":{}}
{"id": 4, "name": "茎わかめ"}

一番下に一行空けないとエラーになってしまう。。

実行コマンド

# テンプレート
$ curl -H 'Content-Type: application/x-ndjson' -XPOST http://{domain}/{index}/_bulk?pretty --data-binary @{json file}.json

$ curl -H 'Content-Type: application/x-ndjson' -XPOST http://0.0.0.0:9200/snacks/_bulk?pretty --data-binary @sample.json
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?