#打开保存的json文件
 with open(self.re_index+'_data'+'.json', 'r',encoding='utf-8' ) as e:
            actions = deque()
            #遍历
            j = 0
            for i in e:
                action =  {
                    '_op_type': 'index',
                    '_index' : json.loads(i)['_index'],
                    '_type' : json.loads(i)['_type'],
                    '_id' : json.loads(i)['_id'],
                    '_source' : json.loads(i)['_source']
                }
                actions.append(action)
            print(len(actions))
       #bulk多线程请求
        for success, info in elasticsearch.helpers.parallel_bulk(es, actions,thread_count=50):
            if not success:
                print('Doc failed', info)
6w条数据,丢了2千多,但是分区是完整的啊,副本设置了为0都没有用
																
															 
														
2 个回复
weizijun - elasticsearch fan
赞同来自:
可以_cat/indices?v 看下是否有deleted记录
正道
赞同来自:
后来导出数据用了scroll和scan的方式,解决了问题,不过比之前取数据稍慢了一些