如何在Elasticsearch中上传批量数据?

时间:2019-03-11 13:25:37

标签: elasticsearch upload logstash kibana bulk

谁能知道在弹性搜索中上传批量数据的过程,我无法在弹性搜索中上传数据。

感谢
高拉夫·辛格(Gaurav Singh)

1 个答案:

答案 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())