【问题标题】:Dumping elastic data into csv or into any NOSQL through python通过 python 将弹性数据转储到 csv 或任何 NOSQL
【发布时间】:2019-02-03 10:33:12
【问题描述】:
正如我们所知,由于连接错误问题,我们无法从弹性搜索中获取超过 10000 行的 python。我想从我的弹性集群中获取两个小时的数据,每 5 分钟,我有大约 10000 次观察。
1.) 如果我可以将弹性搜索中的数据直接转储到 csv 或超过 10000 个计数的 Nosql db 中,有什么办法吗?
我在 python 中编写我的代码。
我使用的是 elasticsearch 版本 5
【问题讨论】:
标签:
python
python-3.x
csv
elasticsearch
elastic-stack
【解决方案1】:
试试下面的滚动查询代码
from elasticsearch import Elasticsearch, helpers
es = Elasticsearch()
es_index = "your_index_name"
documento = "your_doc_type"
body = {
"query": {
"term" : { "user" : user }
}
}
res = helpers.scan(
client = es,
scroll = '2m',
query = body,
index = es_index)