elasticsearch7.12 PHP7数据批量导入遇到的坑
刚开始用python是这样写的:
for line in list: action = { "_index": self.index_name, "_type": self.index_type, "_id": i, "_source": { "date": line['date'], "source": line['source'].encode('utf8').decode('utf8'), "link": line['link'], "keyword": line['keyword'].encode('utf8').decode('utf8'), "title": line['title'].encode('utf8').decode('utf8')} } i += 1 ACTIONS.append(action) # 批量处理 success, _ = bulk(self.es, ACTIONS, index=self.index_name, raise_on_error=True)
后来直接套数据结构进PHP,是这样写的,
public static function itemSynchronize($indexName = 'xxx', $type = '_doc') { $data = se