ElasticSearch批量插入数据

最后更新:2024-09-26 05:30:14 | 状态:未完成 | 相关数据库: ElasticSearch-Elasticsearch
/*
PUT index_user/_bulk
{"index":{"_index":"index_user"}}
{"id":1001, "name":"a b", "age":20}
{"index":{"_index":"index_user", "_id":"10012"}}
{"id":1002, "name":"b c", "age":20}
{"index":{"_index":"index_user", "_id":"10013"}}
{"id":1003, "name":"c d", "age":30}*/
DataSet set = new DataSet();
Long fr = System.currentTimeMillis();
for(int i=0; i<10; i++){
	DataRow row = new ElasticSearchRow();
	row.put("CODE", "C"+i);
	row.put("NAME", "N"+i);
	if(i%3 == 0){
		row.put("_id", fr+i);
		row.setTable(table_name + "_tmp");
	}
	set.add(row);
}
ServiceProxy.insert(table_name, set);
首页 最近更新 搜索 提交 回复