【发布时间】:2019-09-26 17:29:09
【问题描述】:
我正在尝试在 Python 中使用滚动 API,但它在我的整个数据集中循环时遇到了问题。
当应该有超过 150k 个结果时,我得到了大约 100 个返回结果(我可以在 kibana 中看到它们)
附上我的代码
res = helpers.scan(client = es, scroll = '2m', query = {
"size": 10000,
"query": {
"match": {
"type": {
"query": "IP_Address"
}}}},
index = "logstash-*")
# function to return hits from the elasticsearch query in res
def get_es_json(es_scan):
for hits in es_scan:
return hits
# iterate through results with defined number of results
def return_es_results(es_json_data, num_results):
for i in range(num_results):
data = get_es_json(es_json_data)
print(data['_source']['geoip']['asn'])
return_es_results(res, 100)
【问题讨论】:
标签: python json api elasticsearch scroll