【发布时间】:2018-08-31 06:36:41
【问题描述】:
对 Elasticsearch 很陌生,我正在尝试读取 .json 文件并尝试索引该文件。到目前为止,我有这个,但我有点不确定如何从这里开始:
from elasticsearch import Elasticsearch, helpers
import json, sys
es = Elasticsearch()
def load(filename):
if filename.endswith('.json'):
with open(filename, 'r') as open_file:
yield json.load(open_file)
helpers.bulk(es, load(sys.argv[1]), index='my-index', doc_type='my-type')
当我运行它时,我得到错误:helpers.bulk(es, load_json(sys.argv[1]), index='my-index', doc_type='my-type')
IndexError: list index out of range
【问题讨论】:
-
方法名是
load_json' orload`。您的问题有 2 个不同
标签: python json elasticsearch indexing