by Robin at 20240514
This commit is contained in:
parent
5818cc5785
commit
a523664f3a
|
@ -8,6 +8,7 @@ import (
|
|||
"service/dbstruct"
|
||||
"service/library/elasticsearchdb"
|
||||
"service/library/logger"
|
||||
"unicode"
|
||||
|
||||
"service/api/consts"
|
||||
streameracctproto "service/api/proto/streamer_acct/proto"
|
||||
|
@ -70,7 +71,15 @@ func (es *ElasticSearch) GetStreamerAcctListFuzzilyByName(ctx *gin.Context, req
|
|||
|
||||
var nameClause elastic.Query
|
||||
// 查询文字长度小于短语匹配的,进行Term匹配,否则进行短语匹配
|
||||
if len(req.Name) < consts.StreamerAcct_MatchPhraseLen {
|
||||
len := 0
|
||||
for _, char := range req.Name {
|
||||
if unicode.Is(unicode.Han, char) {
|
||||
len++
|
||||
} else {
|
||||
len++
|
||||
}
|
||||
}
|
||||
if len < consts.StreamerAcct_MatchPhraseLen {
|
||||
nameClause = elastic.NewTermQuery("name", req.Name)
|
||||
} else {
|
||||
nameClause = elastic.NewMatchPhraseQuery("name", req.Name)
|
||||
|
@ -105,7 +114,15 @@ func (es *ElasticSearch) GetStreamerAcctListFuzzilyByUserId(ctx *gin.Context, re
|
|||
var nameClause elastic.Query
|
||||
var userIdStringClause elastic.Query
|
||||
// 查询文字长度小于短语匹配的,进行Term匹配,否则进行短语匹配
|
||||
if len(req.UserIdString) < consts.StreamerAcct_MatchPhraseLen {
|
||||
len := 0
|
||||
for _, char := range req.UserIdString {
|
||||
if unicode.Is(unicode.Han, char) {
|
||||
len++
|
||||
} else {
|
||||
len++
|
||||
}
|
||||
}
|
||||
if len < consts.StreamerAcct_MatchPhraseLen {
|
||||
nameClause = elastic.NewTermQuery("name", req.UserIdString)
|
||||
userIdStringClause = elastic.NewTermQuery("user_id_string", req.UserIdString)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue