上代码不多BB
public void batchInsertDocument() throws SolrServerException, IOException {
Integer NUM = 50000;
Integer START = 0;
for (int i = 0; i < 200; i++) {
List<TmStore> queryList = tmStoreMapper.queryByPageSize(i * NUM, NUM);
List<SolrInputDocument> documents = new ArrayList<>();
queryList.forEach(store -> {
SolrInputDocument document = new SolrInputDocument();
document.addField("store_id", store.getStoreId());
document.addField("store_name", store.getStoreName());
document.addField("name", store.getName());
document.addField("phone", store.getPhone());
document.addField("address", store.getAddress());
document.addField("locate", store.getLocate());
documents.add(document);
});
solrClient.add(documents);
solrClient.commit();
}
}
<select id="queryByPageSize" resultType="com.xxjob.domain.TmStore">
select store_id, store_name ,name,phone,locate from tm_store limit ${start},${end}
</select>