标签:single requests build pre exe cse mat == orm
private static TransportClient client = ElasticSearch.getClientSingle();
BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
List<Map<String,Object>> data = tbInformationMapper.tbData(map);
for(int i = 0; i < data.size(); i++) {
Map<String, Object> data= data.get(i);
bulkRequestBuilder.add(client.prepareIndex(index, type, data.get("id").toString()).setSource(data));
if (i % 1000 == 0) {
bulkRequestBuilder.execute().actionGet();
bulkRequestBuilder.request().requests().clear();
}
}
if(!bulkRequestBuilder.request().requests().isEmpty()) {
bulkRequestBuilder.execute().actionGet();
bulkRequestBuilder.request().requests().clear();
}
标签:single requests build pre exe cse mat == orm
原文地址:https://www.cnblogs.com/changeEveryDay/p/12625352.html