xyxie 2 hónapja
szülő
commit
98080874a2
1 módosított fájl, 8 hozzáadás és 8 törlés
  1. 8 8
      services/elastic/chart_collect.go

+ 8 - 8
services/elastic/chart_collect.go

@@ -63,16 +63,16 @@ func SearchChartCollectData(indexName, keywordStr string, userId int, permission
 			})
 		}
 	}
-	/*mustMap = append(mustMap, map[string]interface{}{
-		"bool": shouldMap,
-	})*/
-
+	boolMap := map[string]interface{}{
+		"must": mustMap,
+	}
+	if len(shouldItemMap) > 0 {
+		boolMap["should"] = shouldItemMap
+		boolMap["minimum_should_match"] = 1
+	}
 	queryMap := map[string]interface{}{
 		"query": map[string]interface{}{
-			"bool": map[string]interface{}{
-				"must":   mustMap,
-				"should": shouldItemMap,
-			},
+			"bool": boolMap,
 		},
 	}
 	jsonBytes, _ := json.Marshal(queryMap)