我正在尝试使用python pyes模块将具有6M记录的csv文件索引到elasticsearch,代码逐行读取记录并将其推送到elasticsearch...知道如何将其作为批量发送吗?
import csv
from pyes import *
import sys
header = ['col1','col2','col3','col3', 'col4', 'col5', 'col6']
conn = ES('xx.xx.xx.xx:9200')
counter = 0
for row in reader:
#print len(row)
if counter >= 0:
if counter == 0:
pass
else:
colnum = 0
data = {}
for j in row:
data[header[colnum]] = str(j)
colnum += 1
print data
print counter
conn.index(data,'accidents-index',"accidents-type",counter)
else:
break
counter += 1