浏览代码

修改 删除索引改成清除索引数据

wangxingwang 6 年之前
父节点
当前提交
6a4b350875
共有 1 个文件被更改,包括 6 次插入10 次删除
  1. 6 10
      src/main/java/com/yihu/quota/service/cube/ElasticSearchDataProcessService.java

+ 6 - 10
src/main/java/com/yihu/quota/service/cube/ElasticSearchDataProcessService.java

@ -193,10 +193,10 @@ public class ElasticSearchDataProcessService {
                String cubeId = "";
                if (dataMap.containsKey("cubeId")) {
                    cubeId = dataMap.remove("cubeId").toString();
                    String index = this.getIndexTypeById(cubeId);
                    try {
                        elasticSearchUtil.remove(index);
                    } catch (Exception e) {
                    Cube cube = this.getIndexTypeById(cubeId);
                    if (null != cube) {
                        elasticSearchUtil.deleteByField(cube.getIndexName(), cube.getIndexType(), "_index", cube.getIndexName());
                    } else {
                        throw new  Exception("索引不存在");
                    }
                }
@ -487,13 +487,9 @@ public class ElasticSearchDataProcessService {
     * @param cubeId
     * @return
     */
    public String getIndexTypeById(String cubeId) {
        String index = "";
    public Cube getIndexTypeById(String cubeId) {
        Cube cube = cubeService.findOne(Integer.parseInt(cubeId));
        if (null != cube) {
            index = cube.getIndexName();
        }
        return index;
        return cube;
    }
}