Elasticsearch 批量导入数据
2018-05-02 本文已影响81人
已不再更新_转移到qiita
本人的 Elasticsearch 版本是 6.2.3
python script
from datetime import datetime
from elasticsearch import Elasticsearch
from elasticsearch import helpers
es = Elasticsearch()
#es = Elasticsearch("http://localhost:9200/)
#es = Elasticsearch("http://localhost:9200/test/one")
actions = [
{
"_index": "test",
"_type": "one",
"_id": j,
"_source": {
"any":"data" + str(j),
"timestamp": datetime.now()}
}
for j in range(0, 10)
]
helpers.bulk(es, actions)
参考: