浏览代码

fix:二次分词

wangshan 3 年之前
父节点
当前提交
d9389ebf46
共有 2 个文件被更改,包括 14 次插入4 次删除
  1. 14 2
      jyBXCore/rpc/internal/logic/getsearchlistlogic.go
  2. 0 2
      jyBXCore/rpc/util/search.go

+ 14 - 2
jyBXCore/rpc/internal/logic/getsearchlistlogic.go

@@ -93,14 +93,16 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 		//无限制
 		if res.IsLimit == 1 {
 			count, list := util.GetBidSearchData(in)
+			res.KeyWords = in.KeyWords
 			//二次搜索- 一次搜索结果少于一页数据;关键词长度大于三;第一,二页请求;搜索范围包括title;四个条件
 			if len([]rune(in.KeyWords)) > 3 && int(count) < util.SearchPageSize && in.PageNum < 3 && strings.Contains(in.SelectType, "title") {
-				if in.KeyWords = util.HttpEs(in.KeyWords, "ik_smart", IC.DB.Es.Addr); in.KeyWords != "" {
+				if iksk := util.HttpEs(in.KeyWords, "ik_smart", IC.DB.Es.Addr); iksk != "" {
+					iksk_temp := in.KeyWords
+					in.KeyWords = iksk
 					in.SelectType = "title"
 					//最多查两页数据
 					in.PageSize = 2 * in.PageSize
 					_, secondList := util.GetBidSearchData(in)
-					res.KeyWords = in.KeyWords
 					//数据合并 去重 排序
 					list = util.DelRepeatSearchData(list, secondList)
 					count = int64(len(list))
@@ -114,6 +116,16 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 					case count <= util.SearchPageSize:
 						list = list[:count]
 					}
+					var kbool = map[string]bool{}
+					var karr = []string{}
+					for _, v := range strings.Split(fmt.Sprintf("%s+%s", iksk_temp, iksk), "+") {
+						if kbool[v] {
+							continue
+						}
+						karr = append(karr, v)
+						kbool[v] = true
+					}
+					res.KeyWords = strings.Join(karr, "+")
 				}
 			}
 			limitCount := MC.If(in.UserType != "fType", int64(util.SearchPageSize*util.SearchMaxPageNum_PAYED), int64(util.SearchPageSize*util.SearchMaxPageNum)).(int64)

+ 0 - 2
jyBXCore/rpc/util/search.go

@@ -191,7 +191,6 @@ func GetBidSearchData(in *bxcore.SearchReq) (count int64, list []*bxcore.SearchL
 		} else {
 			repl = elastic.GetAllByNgram(INDEX, TYPE, qstr, ``, bidSearch_sort, field, start, int(in.PageSize), 0, false)
 		}
-		logx.Info("------:", len(*repl))
 		if repl != nil && *repl != nil && len(*repl) > 0 {
 			BidListConvert(in.Industry, repl)
 			list = searchListFormart(repl, true)
@@ -327,7 +326,6 @@ func GetSearchQuery(in *bxcore.SearchReq, mustquery string) (qstr string) {
 		}
 		shoulds := []string{}
 		var switchBool = strings.Contains(findfields, "detail") && strings.Contains(findfields, "title") && IC.C.SearchTypeSwitch
-		log.Println("in.KeyWords:", in.KeyWords)
 		for _, v := range strings.Split(in.KeyWords, "+") {
 			//标题 全文搜索 搜索类型开关打开 默认搜索全文;(全文包含标题)(单字排除)
 			if switchBool && len([]rune(elastic.ReplaceYH(v))) > 1 {