优化日志查询

This commit is contained in:
zlt
2019-01-24 11:11:15 +08:00
parent f78c0988e3
commit 0cce84bb1f
2 changed files with 7 additions and 21 deletions
@@ -38,11 +38,9 @@ public class SlowQueryLogController extends LogController<SlowQueryLog> {
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);
@@ -40,25 +40,13 @@ public class SysLogController extends LogController<SysLog> {
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);
}
}