瀏覽代碼

Merge branch 'dev' of chenweida/jkzl-start into dev

chenweida 7 年之前
父節點
當前提交
7f56779a99
共有 1 個文件被更改,包括 16 次插入5 次删除
  1. 16 5
      common-data-es-starter/src/main/java/com/yihu/base/es/config/ElastricSearchHelper.java

+ 16 - 5
common-data-es-starter/src/main/java/com/yihu/base/es/config/ElastricSearchHelper.java

@ -98,7 +98,13 @@ public class ElastricSearchHelper {
        return br.isSucceeded();
    }
    /**
     * 更新
     * @param index
     * @param type
     * @param sms
     * @return
     */
    public Boolean update(String index, String type, List<Object> sms) {
        JestClient jestClient = null;
        BulkResult br = null;
@ -140,7 +146,12 @@ public class ElastricSearchHelper {
    /**
     * 修改
     * 跟新
     * @param index
     * @param type
     * @param _id
     * @param source
     * @return
     */
    public boolean update(String index, String type, String _id, JSONObject source) {
        JestClient jestClient = null;
@ -166,21 +177,21 @@ public class ElastricSearchHelper {
    /**
     * 删除
     */
    public void delete(String index, String type, List<Object> ESIDEntitys) {
    public void delete(String index, String type, List<Object> datas) {
        JestClient jestClient = null;
        try {
            jestClient = elasticFactory.getJestClient();
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(index).defaultType(type);
            for (Object obj : ESIDEntitys) {
            for (Object obj : datas) {
                Delete indexObj = new Delete.Builder(((ESIDEntity) obj).getId()).build();
                bulk.addAction(indexObj);
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("delete data count:" + ESIDEntitys.size());
            logger.info("delete data count:" + datas.size());
            logger.info("delete flag:" + br.isSucceeded());
        } catch (Exception e) {
            e.printStackTrace();