Created
July 26, 2015 20:53
-
-
Save meddulla/dc39f45460c695443d32 to your computer and use it in GitHub Desktop.
using jq to import json to elastic search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 @- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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...