From 0cce84bb1f94af6ad513a09e49fb54b459221bda Mon Sep 17 00:00:00 2001 From: zlt Date: Thu, 24 Jan 2019 11:11:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SlowQueryLogController.java | 8 +++----- .../log/controller/SysLogController.java | 20 ++++--------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/zlt-monitor/log-center/src/main/java/com/central/log/controller/SlowQueryLogController.java b/zlt-monitor/log-center/src/main/java/com/central/log/controller/SlowQueryLogController.java index 0c974b66..a3919844 100644 --- a/zlt-monitor/log-center/src/main/java/com/central/log/controller/SlowQueryLogController.java +++ b/zlt-monitor/log-center/src/main/java/com/central/log/controller/SlowQueryLogController.java @@ -38,11 +38,9 @@ public class SlowQueryLogController extends LogController { BoolQueryBuilder builder = QueryBuilders.boolQuery(); String searchKey = (String) params.get("searchKey"); String searchValue = (String) params.get("searchValue"); - if (StrUtil.isNotEmpty(searchKey)) { - if (ES_PARAM_QUERY.equals(searchKey)) { - // 模糊查询 - builder.must(QueryBuilders.matchPhraseQuery(ES_PARAM_QUERY, searchValue.toUpperCase())); - } + if (StrUtil.isNotEmpty(searchKey) && StrUtil.isNotEmpty(searchValue)) { + // 模糊查询 + builder.must(QueryBuilders.matchPhraseQuery(ES_PARAM_QUERY, searchValue)); } return super.getPage(params, builder, logDao); diff --git a/zlt-monitor/log-center/src/main/java/com/central/log/controller/SysLogController.java b/zlt-monitor/log-center/src/main/java/com/central/log/controller/SysLogController.java index a861d812..f03e41f7 100644 --- a/zlt-monitor/log-center/src/main/java/com/central/log/controller/SysLogController.java +++ b/zlt-monitor/log-center/src/main/java/com/central/log/controller/SysLogController.java @@ -40,25 +40,13 @@ public class SysLogController extends LogController { BoolQueryBuilder builder = QueryBuilders.boolQuery(); String searchKey = (String) params.get("searchKey"); String searchValue = (String) params.get("searchValue"); - if (StrUtil.isNotEmpty(searchKey)) { - if (ES_PARAM_MESSAGE.equals(searchKey)) { - // 整词模糊查询 日志信息 - builder.must(QueryBuilders.matchPhraseQuery(ES_PARAM_MESSAGE, searchValue)); - } + if (StrUtil.isNotEmpty(searchKey) && StrUtil.isNotEmpty(searchValue)) { if (ES_PARAM_LOG_LEVEL.equals(searchKey)) { - // 模糊查询 - builder.must(QueryBuilders.matchPhraseQuery(ES_PARAM_LOG_LEVEL, searchValue.toUpperCase())); - } - if (ES_PARAM_APP_NAME.equals(searchKey)) { - // 模糊查询 - builder.must(QueryBuilders.fuzzyQuery(ES_PARAM_APP_NAME, searchValue)); - } - if (ES_PARAM_CLASSNAME.equals(searchKey)) { - // 模糊查询 - builder.must(QueryBuilders.fuzzyQuery(ES_PARAM_CLASSNAME, searchValue)); + searchValue = searchValue.toUpperCase(); } + // 模糊查询 + builder.must(QueryBuilders.matchPhraseQuery(searchKey, searchValue)); } - return super.getPage(params, builder, logDao); } }