Преглед на файлове

Merge branch 'feature/pool416_data_business_search' into debug

xyxie преди 3 дни
родител
ревизия
e863e6bccf
променени са 1 файла, в които са добавени 19 реда и са изтрити 33 реда
  1. 19 33
      services/elastic/elastic.go

+ 19 - 33
services/elastic/elastic.go

@@ -1978,60 +1978,46 @@ func SearchDataSourceIndex(indexName, keyword string, source, subSource int, cla
 	shouldMap := make(map[string]interface{}, 0)
 	if keyword != "" {
 		shouldMap["should"] = []interface{}{
-			// 精确匹配,最高优先级
 			map[string]interface{}{
-				"term": map[string]interface{}{
-					"IndexCode.keyword": map[string]interface{}{
-						"value": keyword,
-						"boost": 10,
-					},
-				},
-			},
-			map[string]interface{}{
-				"term": map[string]interface{}{
-					"IndexName.keyword": map[string]interface{}{
-						"value": keyword,
-						"boost": 10,
-					},
-				},
-			},
-			// 短语匹配,次高优先级
-			map[string]interface{}{
-				"match_phrase": map[string]interface{}{
+				"match": map[string]interface{}{
 					"IndexCode": map[string]interface{}{
-						"query": keyword,
-						"boost": 5,
+						"query":  keyword,
+						"operator": "and",
 					},
 				},
 			},
 			map[string]interface{}{
-				"match_phrase": map[string]interface{}{
+				"match": map[string]interface{}{
 					"IndexName": map[string]interface{}{
-						"query": keyword,
-						"boost": 5,
+						"query":    keyword,
+						"operator": "and",
 					},
 				},
 			},
-			// 分词匹配,最低优先级
 			map[string]interface{}{
-				"match": map[string]interface{}{
+				"match_phrase": map[string]interface{}{
 					"IndexCode": map[string]interface{}{
-						"query": keyword,
-						"boost": 1,
+						"query":  keyword,
+						"boost":  5,
 					},
 				},
 			},
 			map[string]interface{}{
-				"match": map[string]interface{}{
+				"match_phrase": map[string]interface{}{
 					"IndexName": map[string]interface{}{
-						"query": keyword,
-						"boost": 1,
+						"query":  keyword,
+						"boost":  5,
 					},
 				},
 			},
 		}
-		// 设置最小匹配度要求
-		shouldMap["minimum_should_match"] = 1
+		//queryFields := []string{"IndexName.keyword", "IndexName.ik", "IndexName.ngram", "IndexCode.keyword", "IndexCode.ngram"}
+		//mustMap = append(mustMap, map[string]interface{}{
+		//	"multi_match": map[string]interface{}{
+		//		"query":  keyword,
+		//		"fields": queryFields,
+		//	},
+		//})
 	}
 
 	// 来源/子来源