mirror of
https://github.com/lzh-1625/go_process_manager.git
synced 2025-09-27 04:16:04 +08:00
1
This commit is contained in:
@@ -88,13 +88,11 @@ type LogResp struct {
|
||||
}
|
||||
|
||||
type ProcessLog struct {
|
||||
Id int `json:"id,omitempty" gorm:"primaryKey;autoIncrement;column:id" `
|
||||
Log string `json:"log" gorm:"column:log"`
|
||||
Word string `json:"word,omitempty"`
|
||||
Logkeyword string `json:"logkeyword,omitempty"`
|
||||
Time int64 `json:"time" gorm:"column:time"`
|
||||
Name string `json:"name" gorm:"column:name"`
|
||||
Using string `json:"using" gorm:"column:using"`
|
||||
Id int `json:"id,omitempty" gorm:"primaryKey;autoIncrement;column:id" `
|
||||
Log string `json:"log" gorm:"column:log"`
|
||||
Time int64 `json:"time" gorm:"column:time"`
|
||||
Name string `json:"name" gorm:"column:name"`
|
||||
Using string `json:"using" gorm:"column:using"`
|
||||
}
|
||||
|
||||
func (n *ProcessLog) TableName() string {
|
||||
|
@@ -42,8 +42,6 @@ func (b *bleveSearch) Init() error {
|
||||
mapping := bleve.NewDocumentMapping()
|
||||
log := bleve.NewTextFieldMapping()
|
||||
log.Index = true
|
||||
logkeyword := bleve.NewKeywordFieldMapping()
|
||||
logkeyword.Index = true
|
||||
time := bleve.NewNumericFieldMapping()
|
||||
time.Index = true
|
||||
name := bleve.NewKeywordFieldMapping()
|
||||
@@ -51,7 +49,6 @@ func (b *bleveSearch) Init() error {
|
||||
using := bleve.NewKeywordFieldMapping()
|
||||
using.Index = true
|
||||
mapping.AddFieldMappingsAt("log", log)
|
||||
mapping.AddFieldMappingsAt("logkeyword", logkeyword)
|
||||
mapping.AddFieldMappingsAt("time", time)
|
||||
mapping.AddFieldMappingsAt("name", name)
|
||||
mapping.AddFieldMappingsAt("using", using)
|
||||
@@ -70,11 +67,10 @@ func (b *bleveSearch) Init() error {
|
||||
|
||||
func (b *bleveSearch) Insert(logContent string, processName string, using string, ts int64) {
|
||||
if err := b.index.Index(uuid.NewString(), model.ProcessLog{
|
||||
Log: logContent,
|
||||
Name: processName,
|
||||
Logkeyword: logContent,
|
||||
Using: using,
|
||||
Time: ts,
|
||||
Log: logContent,
|
||||
Name: processName,
|
||||
Using: using,
|
||||
Time: ts,
|
||||
}); err != nil {
|
||||
logger.Logger.Warnw("bleve log insert failed", "err", err)
|
||||
}
|
||||
@@ -95,11 +91,11 @@ func (b *bleveSearch) Search(req model.GetLogReq, filterProcessName ...string) (
|
||||
buildQuery.AddMustNot(logQuery)
|
||||
case sr.WildCard:
|
||||
logQuery := bleve.NewWildcardQuery("*" + v.Content + "*")
|
||||
logQuery.SetField("logkeyword")
|
||||
logQuery.SetField("log")
|
||||
buildQuery.AddMust(logQuery)
|
||||
case sr.NotWildCard:
|
||||
logQuery := bleve.NewWildcardQuery("*" + v.Content + "*")
|
||||
logQuery.SetField("logkeyword")
|
||||
logQuery.SetField("log")
|
||||
buildQuery.AddMustNot(logQuery)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user