Browse Source

fix:报告标题也可以搜索

Roc 7 months ago
parent
commit
9890196587
1 changed files with 19 additions and 1 deletions
  1. 19 1
      services/elastic/report.go

+ 19 - 1
services/elastic/report.go

@@ -35,6 +35,15 @@ func SearchESEnglishReport(keyWord string, from, size int64) (searchResp *elasti
 				},
 			},
 		},
+		map[string]interface{}{
+			"match": map[string]interface{}{
+				"Title": map[string]interface{}{
+					"query": keyWord,
+					//"minimum_should_match": "60%",
+					"boost": 1,
+				},
+			},
+		},
 		map[string]interface{}{
 			"match_phrase": map[string]interface{}{
 				"Abstract": map[string]interface{}{
@@ -52,6 +61,14 @@ func SearchESEnglishReport(keyWord string, from, size int64) (searchResp *elasti
 				},
 			},
 		},
+		map[string]interface{}{
+			"match_phrase": map[string]interface{}{
+				"Title": map[string]interface{}{
+					"query": keyWord,
+					"boost": 3,
+				},
+			},
+		},
 	}
 	mustMap := map[string]interface{}{
 		"bool": map[string]interface{}{
@@ -83,11 +100,12 @@ func SearchESEnglishReport(keyWord string, from, size int64) (searchResp *elasti
 	source["size"] = size
 	source["highlight"] = map[string]interface{}{
 		"fields": map[string]interface{}{
-			"Abstract":    map[string]interface{}{},
+			"Abstract": map[string]interface{}{},
 			"BodyContent": map[string]interface{}{
 				//	"pre_tags" : "{{highlight}}",
 				//	"post_tags": "{{/highlight}}",
 			},
+			"Title": map[string]interface{}{},
 		},
 		"pre_tags":  "<span style=\"color:#00459F\">",
 		"post_tags": "</span>",