使用elasticsearch_dsl获取所有行 [英] Fetch all the rows using elasticsearch_dsl
本文介绍了使用elasticsearch_dsl获取所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当前我正在使用以下程序从弹性搜索中提取ID及其严重性信息。
Currently i am using the following program to extract the id and its severity information from elastic search .
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search, Q
client = Elasticsearch(
[
#'http://user:secret@10.x.x.11: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行。我需要获取所有信息。
i believe by default the query returns 10 rows. I am having more than 10000 rows in elastic search. I need to fetch all the information.
有人可以指导我如何运行相同的查询以获取所有记录吗?
Can some one guide me how to run the same query to fetch all records ?
推荐答案
您可以使用 scan ()
辅助功能,以便从 test
索引中检索所有文档:
You can use the scan()
helper function in order to retrieve all docs from your test
index:
from elasticsearch import Elasticsearch, helpers
client = Elasticsearch(
[
#'http://user:secret@10.x.x.11: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"
这篇关于使用elasticsearch_dsl获取所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文