Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
elasticsearch scan api snippet
from elasticsearch import Elasticsearch
from elasticsearch import helpers
res = es.search(index="filebeat-*", body={"filter": {"and": [{"range": {"@timestamp": {"gte": formattedBeginTime, "lte": formattedEndTime}}},
{"query": {"term": {"Type": "TRAFFIC"}}}]}}, size=0)
hits = res['hits']['total']
print "Processing {} documents".format(hits)
res = helpers.scan(es,
query={"filter": {"and": [{"range": {"@timestamp": {"gte": formattedBeginTime, "lte": formattedEndTime}}},
{"query": {"term": {"Type": "TRAFFIC"}}}]}},
index="filebeat-*", scroll=u'480m'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment