Skip to content

Instantly share code, notes, and snippets.

@meddulla
Created July 26, 2015 20:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meddulla/dc39f45460c695443d32 to your computer and use it in GitHub Desktop.
Save meddulla/dc39f45460c695443d32 to your computer and use it in GitHub Desktop.
using jq to import json to elastic search
# inspired by http://kevinmarsh.com/2014/10/23/using-jq-to-import-json-into-elasticsearch.html (didn't work but this did)
cat sampledata.json | jq -c '{"index": {"_index": "disco", "_type": "disco", "_id": .id}}, .' | curl -XPOST localhost:9200/_bulk --data-binary @-
@olyerickson
Copy link

Thanks for this!
We've found it is necessary to specify the Content-Type in the curl header:
curl -H "Content-Type: application/json" -XPOST localhost:9200/_bulk --data-binary @-
This might be due to recent updates to the elasticsearch API...

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