|
@@ -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
|