Skip to content

Instantly share code, notes, and snippets.

@brusic
Created September 30, 2014 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brusic/e9a4fa6393576425abb3 to your computer and use it in GitHub Desktop.
Save brusic/e9a4fa6393576425abb3 to your computer and use it in GitHub Desktop.
Convert Elasticsearch search results to Elasticsearch bulk index format
sed -e 's/{"took":[0-9]*,"timed_out":false,"_shards":{"total":[0-9]*,"successful":[0-9]*,"failed":0},"hits":{"total":[0-9]*,"max_score":[0-9\.]*,"hits":\[\(.*\)\]}}$/\1/' -e 's/}},/}}\n/g' -e 's/{"_index"/{ "index":{"_index"/' -e 's/,"_score":[0-9\.]*, "_source" : /}}\n/g'
sed -e 's/{"took":[0-9]*,"timed_out":false,"_shards":{"total":[0-9]*,"successful":[0-9]*,"failed":0},"hits":{"total":[0-9]*,"max_score":[0-9\.]*,"hits":\[\(.*\)\]}}$/\1/' -e 's/}},/}}\
/g' -e 's/{"_index"/{ "index":{"_index"/' -e 's/,"_score":[0-9\.]*, "_source" : /}}\
/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment