xingzai 2 lat temu
rodzic
commit
368c641c80
1 zmienionych plików z 10 dodań i 10 usunięć
  1. 10 10
      services/elastic.go

+ 10 - 10
services/elastic.go

@@ -690,17 +690,17 @@ func EsArticleSearchBody(keyWord string, startSize, pageSize int, orderColumn st
 			},
 		},
 	}
-	//把第一次键入词的筛选条件过滤掉
-	//if ikType == 2 {
-	queryMap = map[string]interface{}{
-		"query": map[string]interface{}{
-			"bool": map[string]interface{}{
-				"must":     mustMap,
-				"must_not": mustNotMap,
+	//把第一次的筛选条件过滤掉
+	if searchType == 2 {
+		queryMap = map[string]interface{}{
+			"query": map[string]interface{}{
+				"bool": map[string]interface{}{
+					"must":     mustMap,
+					"must_not": mustNotMap,
+				},
 			},
-		},
+		}
 	}
-	//}
 	if orderColumn == "Matching" {
 		queryMap["sort"] = sortMap
 	}
@@ -709,7 +709,7 @@ func EsArticleSearchBody(keyWord string, startSize, pageSize int, orderColumn st
 	queryMap["highlight"] = highlightMap
 	jsonBytes, _ := json.Marshal(queryMap)
 	fmt.Println(string(jsonBytes))
-	//utils.FileLog.Info(string(jsonBytes))
+	utils.FileLog.Info(string(jsonBytes))
 	request := client.Search(indexName).Source(queryMap) // sets the JSON request
 	searchByMatch, err := request.Do(context.Background())
 	if searchByMatch != nil {