本人的 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)
参考:
网友评论