Skip to content

Instantly share code, notes, and snippets.

@cknoxrun
Created October 5, 2017 16:49
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 cknoxrun/09673446937c2b945c1d4b9eedf605eb to your computer and use it in GitHub Desktop.
Save cknoxrun/09673446937c2b945c1d4b9eedf605eb to your computer and use it in GitHub Desktop.
client = Elasticsearch::Client.new(log: false, host: SMPDB_ES_URL)
hits = []
search = client.search(index: SMPDB_INDEX, scroll: '5m', body: json)
hits.concat(search['hits']['hits'].map { |hit| SmpdbPathway.new(Hashie::Mash.new(hit['_source'])) })
# Call the `scroll` API until empty results are returned
while search = client.scroll(scroll_id: search['_scroll_id'], scroll: '5m') and not search['hits']['hits'].blank? do
hits.concat(search['hits']['hits'].map { |hit| SmpdbPathway.new(Hashie::Mash.new(hit['_source'])) })
end
return hits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment