Compare commits

5 Commits

Author SHA1 Message Date
lzh
2e37eae3ca 1 2025-09-03 16:52:16 +08:00
lzh
9f7f0c9dd7 1 2025-09-03 16:44:57 +08:00
lzh
1102a60425 1 2025-09-03 16:44:21 +08:00
lzh
8a29bf610c 1 2025-09-03 16:36:38 +08:00
lzh
056caf5d06 edit es search rule 2025-09-03 16:34:19 +08:00

View File

@@ -3,7 +3,6 @@ package es
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"fmt"
"net/http" "net/http"
"time" "time"
@@ -84,16 +83,15 @@ func (e *esSearch) Search(req model.GetLogReq, filterProcessName ...string) mode
for _, v := range sr.QueryStringAnalysis(req.Match.Log) { for _, v := range sr.QueryStringAnalysis(req.Match.Log) {
switch v.Cond { switch v.Cond {
case sr.Match: case sr.Match:
queryList = append(queryList, elastic.NewMatchQuery("log", v.Content)) queryList = append(queryList, elastic.NewMatchQuery("log", v.Content).Boost(2))
queryList = append(queryList, elastic.NewMatchPhraseQuery("log", v.Content))
case sr.NotMatch: case sr.NotMatch:
notQuery = append(notQuery, elastic.NewMatchQuery("log", v.Content)) notQuery = append(notQuery, elastic.NewMatchPhraseQuery("log", v.Content))
case sr.WildCard: case sr.WildCard:
queryList = append(queryList, elastic.NewWildcardQuery("log.keyword", "*"+v.Content+"*")) queryList = append(queryList, elastic.NewWildcardQuery("log.keyword", "*"+v.Content+"*"))
case sr.NotWildCard: case sr.NotWildCard:
notQuery = append(notQuery, elastic.NewWildcardQuery("log.keyword", "*"+v.Content+"*")) notQuery = append(notQuery, elastic.NewWildcardQuery("log.keyword", "*"+v.Content+"*"))
} }
fmt.Printf("v.Cond: %v\n", v.Cond)
fmt.Printf("v.Content: %v\n", v.Content)
} }
if req.Match.Name != "" { if req.Match.Name != "" {