0.9.0 支持分类(系统)筛选检索

This commit is contained in:
gotoeasy 2023-04-24 22:59:46 +08:00
parent 40bec240c7
commit b03ff7b39a
10 changed files with 34 additions and 14 deletions

View File

@ -179,6 +179,11 @@ func main() {
- [ ] 集群支持动态删减节点(或是页面管理删除)
### 版本`0.9.0`
- [x] 增加分类(系统)检索条件,支持多系统时准确筛选
- [x] 修复一些小瑕疵
### 版本`0.8.8`
- [x] 增加时间范围检索条件

View File

@ -3,7 +3,7 @@ module glc
go 1.20
require (
github.com/gotoeasy/glang v0.0.0-20221215063310-d39cd67685c4
github.com/gotoeasy/glang v0.0.0-20230424145432-766531f4dfc6
github.com/syndtr/goleveldb v1.0.0
)

View File

@ -59,8 +59,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gotoeasy/glang v0.0.0-20221215063310-d39cd67685c4 h1:oPNNL1xjus3RvIln/n3mWG2raL+NciiQRD1+dyZZ0oE=
github.com/gotoeasy/glang v0.0.0-20221215063310-d39cd67685c4/go.mod h1:zRo6xc3N5z/VsPCKHlmEz/Uz9XyiQbV3IAv3xsSTPV8=
github.com/gotoeasy/glang v0.0.0-20230424145432-766531f4dfc6 h1:BjHTPALXOecu31LReGpv1AR7W1O8f9xnaqjwPfOHLYw=
github.com/gotoeasy/glang v0.0.0-20230424145432-766531f4dfc6/go.mod h1:zRo6xc3N5z/VsPCKHlmEz/Uz9XyiQbV3IAv3xsSTPV8=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huichen/sego v0.0.0-20210824061530-c87651ea5c76 h1:qNQ2+1IQT9Mor/vfEHePOQSbiapLoNI7sQmpxM7l1Ew=
github.com/huichen/sego v0.0.0-20210824061530-c87651ea5c76/go.mod h1:Fymg8+khR/cKSuIwqRxy/jmZg7PIPLk7CauXzrbcMUM=

View File

@ -43,7 +43,7 @@ func (e *Engine) AddTextLog(date string, logText string, system string) {
e.logStorage.AddTextLog(date, logText, system)
}
func (e *Engine) Search(searchKey string, minDatetime string, maxDatetime string, pageSize int, currentDocId uint32, forward bool) *search.SearchResult {
func (e *Engine) Search(searchKey string, system string, minDatetime string, maxDatetime string, pageSize int, currentDocId uint32, forward bool) *search.SearchResult {
// 检查修正pageSize
if pageSize < 1 {
@ -54,7 +54,9 @@ func (e *Engine) Search(searchKey string, minDatetime string, maxDatetime string
}
// 分词后检索
kws := tokenizer.CutForSearch(searchKey) // TODO 检索用关键词处理
var adds []string
adds = append(adds, system)
kws := tokenizer.CutForSearchEx(searchKey, adds, nil) // 检索用关键词处理
if searchKey == "" {
cmn.Debug("无条件查询", "currentDocId =", currentDocId)

View File

@ -46,7 +46,7 @@ func Test_all(t *testing.T) {
// }
// time.Sleep(time.Duration(5) * time.Second)
rs := engine.Search(` them java `, "", "", 5, 0, true)
rs := engine.Search(` them java `, "", "", "", 5, 0, true)
cmn.Println("共查到", rs.Total, "件")
for _, v := range rs.Data {
cmn.Println(v.Id, v.Text)

View File

@ -16,13 +16,14 @@ import (
type LogDataModel struct {
Id string `json:"id,omitempty"` // 从1开始递增(36进制字符串)
Text string `json:"text,omitempty"` // 【必须】日志内容,多行时仅为首行,直接显示用,是全文检索对象
Detail string `json:"detail,omitempty"` // 多行时的详细日志信息,通常是包含错误堆栈等的日志内容
Date string `json:"date,omitempty"` // 日期(格式自定义
Detail string `json:"detail,omitempty"` // 多行时的详细日志信息,通常是包含错误堆栈等的日志内容(这部分内容不做索引处理)
Date string `json:"date,omitempty"` // 日期(格式YYYY/MM/DD HH:MM:SS.SSS
Tags []string `json:"tags,omitempty"` // 自定义标签,都作为关键词看待处理
Server string `json:"server,omitempty"` // 服务器
Client string `json:"client,omitempty"` // 客户端
User string `json:"user,omitempty"` // 用户
System string `json:"system,omitempty"` // 所属系统
LogType string `json:"logtype,omitempty"` // 日志类型(如登录日志、操作日志)
TraceId string `json:"traceid,omitempty"` // 跟踪ID
Keywords []string `json:"keywords,omitempty"` // 自定义的关键词
Sensitives []string `json:"sensitives,omitempty"` // 要删除的敏感词

View File

@ -182,8 +182,8 @@ func (s *LogDataStorage) createInvertedIndex() int {
// 整理关键词
adds := docm.Keywords
adds = append(adds, docm.Tags...)
adds = append(adds, docm.Client, docm.Server, docm.System, docm.User)
kws := tokenizer.CutForSearchEx(docm.Text, adds, docm.Sensitives) // 两数组参数的元素可以重复或空白,会被判断整理
adds = append(adds, docm.Client, docm.Server, "~"+docm.System, docm.User) // 特殊处理system
kws := tokenizer.CutForSearchEx(docm.Text+" "+docm.System, adds, docm.Sensitives) // 两数组参数的元素可以重复或空白,会被判断整理
// 每个关键词都创建反向索引
for _, word := range kws {

View File

@ -1,3 +1,3 @@
package onstart
const VERSION = "glogcenter 0.8.8"
const VERSION = "glogcenter 0.9.0"

View File

@ -23,8 +23,13 @@ func LogSearchController(req *gweb.HttpRequest) *gweb.HttpResult {
forward := cmn.StringToBool(req.GetFormParameter("forward"), true)
datetimeFrom := req.GetFormParameter("datetimeFrom")
datetimeTo := req.GetFormParameter("datetimeTo")
system := req.GetFormParameter("system")
if !cmn.IsBlank(system) {
system = "~" + cmn.Trim(system)
}
eng := ldb.NewEngine(storeName)
rs := eng.Search(searchKey, datetimeFrom, datetimeTo, pageSize, currentId, forward)
rs := eng.Search(searchKey, system, datetimeFrom, datetimeTo, pageSize, currentId, forward)
return gweb.Result(rs)
}

View File

@ -40,7 +40,7 @@
<div v-show="showSearchPanel" class="c-down-panel">
<el-form ref="form" :inline="true" label-width="100">
<el-row>
<el-row>
<el-form-item label="选择日志仓">
<el-select v-if="storageOptions.length > 0" v-model="storage" filterable placeholder="请选择" style="width:420px;">
<el-option
@ -52,6 +52,11 @@
</el-select>
</el-form-item>
</el-row>
<el-row>
<el-form-item label="分类名称">
<el-input v-model="params.system" placeholder="请输入分类名" style="width:420px;"></el-input>
</el-form-item>
</el-row>
<el-row>
<el-form-item label="时间范围">
<el-date-picker
@ -145,6 +150,7 @@ export default {
params: {
storeName: '',
searchKey: '',
system: '',
datetime: null,
pageSize: 100,
currentId: '',
@ -277,12 +283,13 @@ export default {
},
computed:{
hasMoreCondition(){
return !this.params.datetime && !this.storage;
return !this.params.datetime && !this.storage && !this.params.system;
}
},
methods: {
fnResetSearchForm(){
this.params.searchKey = '';
this.params.system = '';
this.params.datetime = null;
this.storage = '';
this.search();