Browse Source

排除词es修改

jiaojiao7 4 năm trước cách đây
mục cha
commit
f0adabf99f
1 tập tin đã thay đổi với 33 bổ sung9 xóa
  1. 33 9
      src/util/utiltag.go

+ 33 - 9
src/util/utiltag.go

@@ -602,6 +602,7 @@ func method1(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []strin
 }
 
 func method2(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []string) sql.NewEsObject {
+	notKeyWordArr := []string{}
 	for _, vv := range strings.Split(keyword, ",") {
 		if vv == "" {
 			continue
@@ -614,7 +615,7 @@ func method2(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []strin
 			//} else {
 			//	strs = ".*" + vv + ".*"
 			//}
-			if tmps[0] == "buyer" {
+			if tmps[0] == "buyer.mbuyer" {
 				newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.ShouldObj{
 					MultiMatch: &sql.MultiMatch{
 						Query:  vv,
@@ -622,7 +623,7 @@ func method2(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []strin
 						Fields: tmps,
 					},
 				})
-			} else if tmps[0] == "s_winner" {
+			} else if tmps[0] == "s_winner.mwinner" {
 				newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.ShouldObj{
 					MultiMatch: &sql.MultiMatch{
 						Query:  vv,
@@ -631,15 +632,18 @@ func method2(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []strin
 					},
 				})
 			}
+		} else if len(tmps) == 1 && (strings.Contains(keymatch, "6") || strings.Contains(keymatch, "7")) {
+			notkeylines := strings.Split(vv, "&&")
+			notKeyWordArr = append(notKeyWordArr, notkeylines[0])
 		} else {
-			addkeylines := strings.Split(vv, "&&")
-			if len(addkeylines) > 1 {
-				addkeyline := sql.NewEsObject{}
-				for _, vvv := range addkeylines {
+			notkeylines := strings.Split(vv, "&&")
+			if len(notkeylines) > 1 {
+				notkeyline := sql.NewEsObject{}
+				for _, vvv := range notkeylines {
 					if vvv == "" {
 						continue
 					}
-					addkeyline.Bool.Must = append(addkeyline.Bool.Must, sql.ShouldObj{
+					notkeyline.Bool.Must = append(notkeyline.Bool.Must, sql.ShouldObj{
 						MultiMatch: &sql.MultiMatch{
 							Query:  vvv,
 							Type:   MultiMatchType,
@@ -647,8 +651,8 @@ func method2(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []strin
 						},
 					})
 				}
-				if len(addkeyline.Bool.Must) > 0 {
-					newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, addkeyline)
+				if len(notkeyline.Bool.Must) > 0 {
+					newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, notkeyline)
 				}
 			} else {
 				newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, sql.ShouldObj{
@@ -661,6 +665,26 @@ func method2(newEsObject sql.NewEsObject, keyword, keymatch string, tmps []strin
 			}
 		}
 	}
+	log.Println("+++++++", tmps, keymatch)
+	if len(tmps) == 1 && (strings.Contains(keymatch, "6") || strings.Contains(keymatch, "7")) {
+		notkeyline := []interface{}{}
+		if tmps[0] == "buyer" {
+			notkeyline = append(notkeyline, sql.BuyerMatch{
+				Buyer: &sql.Buyer{Buyer: notKeyWordArr},
+			})
+
+			//toptypeSubtype := sql.ToptypeSubtype{}
+			//toptypeSubtype.Toptype = strings.Split(tab.Stoptype, ",")
+			//ffBoolObject.Must = append(ffBoolObject.Must, sql.ToptypeSubtypeMust{&toptypeSubtype})
+		} else if tmps[0] == "s_winner" {
+			notkeyline = append(notkeyline, sql.WinnerMatch{
+				Winner: &sql.Winner{Winner: notKeyWordArr},
+			})
+		}
+		if len(notkeyline) > 0 {
+			newEsObject.Bool.MustNot = append(newEsObject.Bool.MustNot, notkeyline)
+		}
+	}
 	return newEsObject
 }