|
@@ -939,34 +939,61 @@ func SearchChartInfoData(indexName, keywordStr string, showSysId []int, sourceLi
|
|
|
})
|
|
|
|
|
|
//关键字匹配
|
|
|
+ //shouldMap := map[string]interface{}{
|
|
|
+ // "should": []interface{}{
|
|
|
+ // map[string]interface{}{
|
|
|
+ // "match": map[string]interface{}{
|
|
|
+ // "ChartName": keywordStr,
|
|
|
+ // //"Frequency.keyword": "月度",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // // 因为关键词被分了,所以需要用下面的语句来让他 整个词 查询,从而加重整词的权重
|
|
|
+ // map[string]interface{}{
|
|
|
+ // "match": map[string]interface{}{
|
|
|
+ // "ChartName": map[string]interface{}{
|
|
|
+ // "query": keywordStr,
|
|
|
+ // "operator": "and",
|
|
|
+ // },
|
|
|
+ // //"Frequency.keyword": "月度",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // map[string]interface{}{
|
|
|
+ // "match": map[string]interface{}{
|
|
|
+ // "ChartNameEn": keywordStr,
|
|
|
+ // //"Frequency.keyword": "月度",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // // 因为关键词被分了,所以需要用下面的语句来让他 整个词 查询,从而加重整词的权重
|
|
|
+ // map[string]interface{}{
|
|
|
+ // "match": map[string]interface{}{
|
|
|
+ // "ChartNameEn": map[string]interface{}{
|
|
|
+ // "query": keywordStr,
|
|
|
+ // "operator": "and",
|
|
|
+ // },
|
|
|
+ // //"Frequency.keyword": "月度",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ //}
|
|
|
+
|
|
|
+ // 默认使用中文名字字段去匹配
|
|
|
+ keywordNameKey := `ChartName`
|
|
|
+ // 如果没有中文,则使用英文名称字段去匹配
|
|
|
+ /*if !utils.ContainsChinese(keywordStr) {
|
|
|
+ keywordNameKey = `ChartNameEn`
|
|
|
+ }*/
|
|
|
shouldMap := map[string]interface{}{
|
|
|
"should": []interface{}{
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "ChartName": keywordStr,
|
|
|
- //"Frequency.keyword": "月度",
|
|
|
- },
|
|
|
- },
|
|
|
- // 因为关键词被分了,所以需要用下面的语句来让他 整个词 查询,从而加重整词的权重
|
|
|
- map[string]interface{}{
|
|
|
+ /*map[string]interface{}{
|
|
|
"match": map[string]interface{}{
|
|
|
- "ChartName": map[string]interface{}{
|
|
|
- "query": keywordStr,
|
|
|
- "operator": "and",
|
|
|
- },
|
|
|
+ keywordNameKey: keywordStr,
|
|
|
//"Frequency.keyword": "月度",
|
|
|
},
|
|
|
- },
|
|
|
- map[string]interface{}{
|
|
|
- "match": map[string]interface{}{
|
|
|
- "ChartNameEn": keywordStr,
|
|
|
- //"Frequency.keyword": "月度",
|
|
|
- },
|
|
|
- },
|
|
|
+ },*/
|
|
|
// 因为关键词被分了,所以需要用下面的语句来让他 整个词 查询,从而加重整词的权重
|
|
|
map[string]interface{}{
|
|
|
"match": map[string]interface{}{
|
|
|
- "ChartNameEn": map[string]interface{}{
|
|
|
+ keywordNameKey: map[string]interface{}{
|
|
|
"query": keywordStr,
|
|
|
"operator": "and",
|
|
|
},
|
|
@@ -975,6 +1002,7 @@ func SearchChartInfoData(indexName, keywordStr string, showSysId []int, sourceLi
|
|
|
},
|
|
|
},
|
|
|
}
|
|
|
+
|
|
|
mustMap = append(mustMap, map[string]interface{}{
|
|
|
"bool": shouldMap,
|
|
|
})
|