Skip to content

Instantly share code, notes, and snippets.

@jhonata-menezes
Created December 20, 2016 17:44
Show Gist options
  • Save jhonata-menezes/574c231c91249133dfd070e0c8acc8aa to your computer and use it in GitHub Desktop.
Save jhonata-menezes/574c231c91249133dfd070e0c8acc8aa to your computer and use it in GitHub Desktop.
Exportar uma collection para json no formato de bulk insert do elasticsearch
#export mongodb to json with pattern elasticsearch bulk insert without _id (mongodb)
mongoexport -h 127.0.0.1 --port 27017 -d db -c collection -f fields | sed '/"_id":/s/"_id":[^,]*,//' | awk '{print "{\"index\": {\"_index\": \"index_name\", \"_type\": \"type_name\"}}\n"$0}' > elasticsearch.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment