|
@ -47,10 +47,11 @@ public class ElastricSearchSave {
|
|
|
try {
|
|
|
obj.setCreateTime(new Date());
|
|
|
Index index = new Index.Builder(obj).build();
|
|
|
success++;
|
|
|
bulk.addAction(index);
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage());
|
|
|
|
|
|
error++;
|
|
|
}
|
|
|
}
|
|
|
BulkResult br = jestClient.execute(bulk.build());
|
|
@ -73,18 +74,6 @@ public class ElastricSearchSave {
|
|
|
int success = 0;
|
|
|
int error = 0;
|
|
|
boolean isSuccessed = true;
|
|
|
// Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
|
|
|
// for (SaveModel obj : sms) {
|
|
|
// try {
|
|
|
// obj.setCreateTime(new Date());
|
|
|
// Update index = new Update.Builder(obj).index(esIndex).type(esType).id(obj.getId()).build();
|
|
|
// bulk.addAction(index);
|
|
|
// success++;
|
|
|
// } catch (Exception e) {
|
|
|
// error++;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
|
|
|
for (SaveModel obj : sms) {
|
|
|
try {
|
|
@ -93,13 +82,7 @@ public class ElastricSearchSave {
|
|
|
jo.put("doc",obj);
|
|
|
Update index = new Update.Builder(jo.toString()).index(esIndex).type(esType).id(obj.getId()).build();
|
|
|
bulk.addAction(index);
|
|
|
// JestResult result = jestClient.execute(index);
|
|
|
// if (result.isSucceeded()) {
|
|
|
// success++;
|
|
|
// } else {
|
|
|
// error++;
|
|
|
// isSuccessed = false;
|
|
|
// }
|
|
|
success++;
|
|
|
} catch (Exception e) {
|
|
|
error++;
|
|
|
isSuccessed = false;
|