Skip to content

Instantly share code, notes, and snippets.

@nailo2c
Created January 8, 2019 10:22
Show Gist options
  • Save nailo2c/daf740e1b82acf1000c716d34f1c89d6 to your computer and use it in GitHub Desktop.
Save nailo2c/daf740e1b82acf1000c716d34f1c89d6 to your computer and use it in GitHub Desktop.
Use ElasticSearch python api to retrieve all data
from elasticsearch import Elasticsearch
from elasticsearch import helpers
es_url = 'https://your/elasticsearch/url/'
index = '*your-index*'
query = {
"query": {
"match_all": {}
}
}
es = Elasticsearch(
[es_url],
use_ssl=True,
request_timeout=30)
scan = helpers.scan(es,
query=query,
index=index,
preserve_order=True)
for item in scan:
print('do something')
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment