Skip to content

Instantly share code, notes, and snippets.

@deveshkharve
Last active February 26, 2020 13:15
Show Gist options
  • Save deveshkharve/8db871d934da94da96d9e5cdd99636dd to your computer and use it in GitHub Desktop.
Save deveshkharve/8db871d934da94da96d9e5cdd99636dd to your computer and use it in GitHub Desktop.
def getData():
query = {
"query": {
"match_all": {}
},
"sort": [
{
"createdAt": {
"order": "desc"
}
},
{
"id": {
"order": "desc"
}
}
],
"size": 5000
}
results = []
esRes = search(query)
results = results + parseData(esRes)
while len(esRes['hits']['hits']) > 0:
resLen = len(esRes['hits']['hits'])
query['search_after'] = esRes['hits']['hits'][resLen-1]['sort']
esRes = search(query)
results = results + parseData(esRes)
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment