Skip to content

Instantly share code, notes, and snippets.

@mudge
Last active June 5, 2016 15:10
Show Gist options
  • Save mudge/6062586 to your computer and use it in GitHub Desktop.
Save mudge/6062586 to your computer and use it in GitHub Desktop.
Convert Elasticsearch search output into bulk format.
paste -d '\n' <(curl 127.0.0.1:9200/collection/_search | jq -c '.hits.hits[] | {"index": {_index, _type, _id}}') <(curl 127.0.0.1:9200/collection/_search | jq -c '.hits.hits[]._source')
@mlgoldworm
Copy link

Thank you. This has saved me a bunch of time!

@PhaedrusTheGreek
Copy link

Or like this as described here

curl -s -XGET "http://127.0.0.1:9200/test/_search" \
  | jq -c '.hits.hits[] | { index: {_index:._index, _type:._type, _id:._id}}, ._source'

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