Skip to content

Instantly share code, notes, and snippets.

@adhendo
Last active February 7, 2022 21:11
Show Gist options
  • Save adhendo/bac8f5a4d7624963b9db32ecee76d499 to your computer and use it in GitHub Desktop.
Save adhendo/bac8f5a4d7624963b9db32ecee76d499 to your computer and use it in GitHub Desktop.
Command line script for bulk json file indexing to Elastic Search
cat example.json | jq -c -r '.[] | {"index": {"_index": "index_name", "_type": "_doc", "_id": .id}}, .' | curl -XPOST -H "Content-Type: application/json" https://elastic_search_url/index_name/_bulk --data-binary @-
@adhendo
Copy link
Author

adhendo commented Jun 29, 2021

example.json refers to your json file you want to index, replace index_name with the name of your index, .id can be whatever property you want from your json file, finally replace elastic_search_url/index_name with your elastic search url and index name respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment