import csv
from elasticsearch import Elasticsearch
from elasticsearch import helpers
es=Elasticsearch(hosts='http://localhost',port=9200)
def gendata():
with open('scripts/assets.csv', 'r', encoding='utf-8') as f:
file = csv.reader(f)
for line in file:
yield {
"_index": "apple",
"_id": line[0],
"_source": {
"ip": line[0],
"ipType": line[1],
"ipPosition": line[2],
}
}
def input_es():
print(helpers.bulk(es, gendata()))
[ElasticSearch7] 批量导入
最新推荐文章于 2022-07-31 22:05:21 发布