目前我正在使用以下程序从弹性搜索中提取 id 及其严重性信息。
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search, Q
client = Elasticsearch(
[
#'http://user:[email protected]:9200/',
'http://10.x.x.11:9200/',
],
verify_certs=True
)
s = Search(using=client, index="test")
response = s.execute()
for hit in response:
print hit.message_id, hit.severity, "\n\n"
我相信默认情况下查询会返回 10 行。我在弹性搜索中有超过 10000 行。我需要获取所有信息。
有人可以指导我如何运行相同的查询来获取所有记录吗?
您可以使用scan()辅助函数为了检索您的所有文档test
index:
from elasticsearch import Elasticsearch, helpers
client = Elasticsearch(
[
#'http://user:[email protected]:9200/',
'http://10.x.x.11:9200/',
],
verify_certs=True
)
docs = list(helpers.scan(client, index="test", query={"query": {"match_all": {}}}))
for hit in docs:
print hit.message_id, hit.severity, "\n\n"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)