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