[英]How to use Elasticsearch bulk index with single JSON file in Python
I have a single JSON file formatted like: 我有一个格式如下的JSON文件:
{"index":{"_type": "summary", "_id": "0001-1200-2015-12-31-0007", "_index": "transaction"}}
{"data_load_user_id": "nathan", "tender_time": 5, "ring_time": 8, "operator_id": "0111"}
for about 12,000 rows. 大约12,000行 As far as I know, this is the correct way to format a JSON file for the bulk API in elasticsearch. 据我所知,这是在Elasticsearch中为批量API格式化JSON文件格式的正确方法。 I'm still confused on how to use es.bulk() with this single file as input. 我仍然对如何将es.bulk()与单个文件作为输入感到困惑。 I already have the index and id specified for each row. 我已经为每一行指定了索引和ID。
好的,所以helpers.bulk()
模块将字典列表和我的helpers.bulk()
客户端作为参数,而不是每个条目JSON文件排2行,我只需要添加"_index"
"type"
和"_id"
每一个JSON字典,它的工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.