谁能知道在弹性搜索中上传批量数据的过程,我无法在弹性搜索中上传数据。
感谢
高拉夫·辛格(Gaurav Singh)
答案 0 :(得分:0)
from elasticsearch import helpers, Elasticsearch
data = [{'id':1, 'content':'some content'}]
INDEX_NAME = 'index'
TYPE = 'list'
def get_actions():
actions = []
for d in data:
action = {
'_op_type': 'update',
"_index": INDEX_NAME,
'_type': TYPE,
"_id": d['id'],
}
actions.append(action)
return(actions)
result = helpers.bulk(Elasticsearch(IP), get_actions())