Skip to content

Instantly share code, notes, and snippets.

@ivarvong
Created February 9, 2015 16:31
Show Gist options
  • Save ivarvong/68e0306ae65cfe45a5b7 to your computer and use it in GitHub Desktop.
Save ivarvong/68e0306ae65cfe45a5b7 to your computer and use it in GitHub Desktop.
require 'elasticsearch'
url = `heroku config --app <heroku-app-name> | grep "SEARCHBOX_SSL_URL:"`.split(": ").last.strip
client = Elasticsearch::Client.new(url: url)
# https://github.com/elasticsearch/elasticsearch-ruby/issues/49
scan_response = client.search(index: 'pixels', search_type: 'scan', scroll: '5m', size: 10)
while response = client.scroll(scroll_id: scan_response['_scroll_id'], scroll: '5m') and !response['hits']['hits'].empty? do
puts response['hits']['hits'].map { |r| r['_source'] }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment