瀏覽代碼

活动搜索

xingzai 2 年之前
父節點
當前提交
103bf0325a
共有 4 個文件被更改,包括 15 次插入18 次删除
  1. 1 1
      controllers/activity.go
  2. 0 1
      services/activity.go
  3. 1 3
      services/activity_special.go
  4. 13 13
      services/elastic.go

+ 1 - 1
controllers/activity.go

@@ -2605,7 +2605,7 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 	pageSizeIk = pageSize - len(list)
 	if pageSizeIk > 0 {
 		//搜索关键词联想
-		conditionActivityIk, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack, 1)
+		conditionActivityIk, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack, 2)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败,Err:" + err.Error()

+ 0 - 1
services/activity.go

@@ -678,7 +678,6 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 		//condition += ` AND art.activity_time > '` + endTime + `'  `
 		if len(ativityVIdArry) > 0 {
 			ativityVIdstr := strings.Join(ativityVIdArry, ",")
-			fmt.Println(ativityVIdstr)
 			condition += ` AND art.activity_id IN  (` + ativityVIdstr + `) `
 		}
 	}

+ 1 - 3
services/activity_special.go

@@ -553,8 +553,7 @@ func GetActivitySpecialSearcheList(user *models.WxUserItem, condition string, st
 		return
 	}
 	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-
-	startSizeIk := startSize - total
+	startSizeIk := startSize - totalSearche
 	if startSizeIk < 0 {
 		startSizeIk = 0
 	}
@@ -578,7 +577,6 @@ func GetActivitySpecialSearcheList(user *models.WxUserItem, condition string, st
 		err = errors.New("HandleActivityListButton, Err: " + e.Error())
 		return
 	}
-
 	return
 }
 

+ 13 - 13
services/elastic.go

@@ -909,20 +909,20 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 	shouldMapquery := make([]interface{}, 0)
 	// @Param   OrderColumn   query   int  true       "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
 	//keyWordWeight := GetWeight(keyWordLen)
-	var boost int
-	lenkeyWordArr := len(keyWordArr)
-	for k, v := range keyWordArr {
-		if k == 0 {
-			boost = 2 * 1000
-		} else {
-			boost = 1000
-		}
+	//var boost int
+	//lenkeyWordArr := len(keyWordArr)
+	for _, v := range keyWordArr {
+		//if k == 0 {
+		//	boost = 2 * 1000
+		//} else {
+		//	boost = 1000
+		//}
 		if v != "" {
 			shouldMapquery = append(shouldMapquery, map[string]interface{}{
 				"function_score": map[string]interface{}{
 					"query": map[string]interface{}{
 						"multi_match": map[string]interface{}{
-							"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+							//"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
 							"fields": []interface{}{"Title"},
 							"query":  v,
 						},
@@ -933,7 +933,7 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 				"function_score": map[string]interface{}{
 					"query": map[string]interface{}{
 						"multi_match": map[string]interface{}{
-							"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+							//"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
 							"fields": []interface{}{"Abstract"},
 							"query":  v,
 						},
@@ -944,7 +944,7 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 				"function_score": map[string]interface{}{
 					"query": map[string]interface{}{
 						"multi_match": map[string]interface{}{
-							"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+							//"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
 							"fields": []interface{}{"Annotation"},
 							"query":  v,
 						},
@@ -955,7 +955,7 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 				"function_score": map[string]interface{}{
 					"query": map[string]interface{}{
 						"multi_match": map[string]interface{}{
-							"boost":  (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
+							//"boost":  (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
 							"fields": []interface{}{"BodyText"},
 							"query":  v,
 						},
@@ -999,7 +999,7 @@ func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string
 			},
 		},
 	}
-	if orderColumn == "Comprehensive" {
+	if orderColumn == "Matching" {
 		queryMap["sort"] = sortMap
 	}
 	queryMap["from"] = startSize