Skip to content

Instantly share code, notes, and snippets.

@scaint
Created February 12, 2017 11:44
Show Gist options
  • Save scaint/ffc5dfb1a6a39ac511d2e7f0446456a1 to your computer and use it in GitHub Desktop.
Save scaint/ffc5dfb1a6a39ac511d2e7f0446456a1 to your computer and use it in GitHub Desktop.
SELECT format(
E'{"index": {"_index": "%s", "_type": "%s", "_id": %s}}\n%s',
current_database() || '_users',
'user',
t.id,
json_build_object('username', t.username, 'email', t.email))
FROM users t;
#!/bin/bash
time (psql -t -U some_user -d some_db < query.sql | curl -s -XPOST localhost:9200/_bulk --data-binary @-)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment