|
@@ -123,51 +123,34 @@ func (kws *KeyWordsSearch) GetSearchKeyWordsQueryStr(in *bxcore.SearchReq) (word
|
|
|
// in.SearchMode 搜索模式:0:精准搜索;1:模糊搜索
|
|
|
// 精准搜索:不分词,完全匹配;(中间带空格的关键词组自动分词)
|
|
|
// 模糊搜索:对用户输入的单个关键词进行分词处理,但必须都存在;
|
|
|
- if in.SearchMode == 1 {
|
|
|
- var (
|
|
|
- keyWords, addWords []string
|
|
|
- )
|
|
|
- //主关键词词组
|
|
|
- if in.KeyWords != "" {
|
|
|
- for _, mv := range strings.Split(in.KeyWords, IC.C.JYKeyMark) {
|
|
|
- if strings.TrimSpace(mv) != "" {
|
|
|
- if ikWords := util.HttpEs(mv, "ik_smart", IC.DB.Es.Addr); ikWords != "" {
|
|
|
- keyWords = append(keyWords, strings.Split(ikWords, IC.C.JYKeyMark)...)
|
|
|
- }
|
|
|
- }
|
|
|
+ //主关键词词组
|
|
|
+ if in.KeyWords != "" {
|
|
|
+ if in.SearchMode == 1 {
|
|
|
+ if ikWords := util.HttpEs(in.KeyWords, "ik_smart", IC.DB.Es.Addr); ikWords != "" {
|
|
|
+ in.KeyWords = ikWords
|
|
|
}
|
|
|
- in.KeyWords = strings.Join(keyWords, IC.C.JYKeyMark)
|
|
|
- words = append(words, in.KeyWords)
|
|
|
}
|
|
|
- //附加词组
|
|
|
- //多组附加词,每组间,号隔开。每组内如果关键词中间有空格,自动分词
|
|
|
- if in.AdditionalWords != "" {
|
|
|
+ words = append(words, in.KeyWords)
|
|
|
+ }
|
|
|
+ //附加词组
|
|
|
+ //多组附加词,每组间,号隔开。每组内如果关键词中间有空格,自动分词
|
|
|
+ if in.AdditionalWords != "" {
|
|
|
+ if in.SearchMode == 1 {
|
|
|
+ var (
|
|
|
+ addWords []string
|
|
|
+ )
|
|
|
for _, awv := range strings.Split(in.AdditionalWords, ",") {
|
|
|
- var (
|
|
|
- addWord []string
|
|
|
- )
|
|
|
- for _, av := range strings.Split(awv, IC.C.JYKeyMark) {
|
|
|
- if strings.TrimSpace(av) != "" {
|
|
|
- if ikWords := util.HttpEs(av, "ik_smart", IC.DB.Es.Addr); ikWords != "" {
|
|
|
- addWord = append(addWord, strings.Split(ikWords, IC.C.JYKeyMark)...)
|
|
|
- }
|
|
|
+ if strings.TrimSpace(awv) != "" {
|
|
|
+ if ikWords := util.HttpEs(awv, "ik_smart", IC.DB.Es.Addr); ikWords != "" {
|
|
|
+ addWords = append(addWords, strings.Split(ikWords, IC.C.JYKeyMark)...)
|
|
|
}
|
|
|
}
|
|
|
- addWords = append(addWords, strings.Join(addWord, IC.C.JYKeyMark))
|
|
|
- addWord = []string{}
|
|
|
}
|
|
|
- words = append(words, addWords...)
|
|
|
- in.AdditionalWords = strings.Join(addWords, ",")
|
|
|
- }
|
|
|
- } else {
|
|
|
- words = append(words, strings.Split(in.KeyWords, IC.C.JYKeyMark)...)
|
|
|
- for _, awv := range strings.Split(in.AdditionalWords, ",") {
|
|
|
- for _, av := range strings.Split(awv, IC.C.JYKeyMark) {
|
|
|
- if strings.TrimSpace(av) != "" {
|
|
|
- words = append(words, strings.Split(av, IC.C.JYKeyMark)...)
|
|
|
- }
|
|
|
+ if len(addWords) > 0 {
|
|
|
+ in.AdditionalWords = strings.Join(addWords, ",")
|
|
|
}
|
|
|
}
|
|
|
+ words = append(words, strings.Split(in.AdditionalWords, ",")...)
|
|
|
}
|
|
|
return
|
|
|
}
|