wcc 2 долоо хоног өмнө
parent
commit
7832282407

+ 49 - 43
project_chuan/project_new.go

@@ -16,7 +16,7 @@ import (
 	"time"
 	"time"
 )
 )
 
 
-func SearchProjectFullScoring(client *elastic.Client, target InputData, projectName, areacode, publish string) ([]map[string]interface{}, error) {
+func SearchProjectFullScoring(client *elastic.Client, target InputData, projectName, areacode, publish string, targetScore float64) ([]map[string]interface{}, error) {
 	seenIDs := make(map[string]*elastic.SearchHit)
 	seenIDs := make(map[string]*elastic.SearchHit)
 
 
 	province, city := "", ""
 	province, city := "", ""
@@ -105,9 +105,15 @@ func SearchProjectFullScoring(client *elastic.Client, target InputData, projectN
 		}
 		}
 
 
 		score := calculateConfidenceScore(target, candidate)
 		score := calculateConfidenceScore(target, candidate)
-		//candidate.Score = score
-		candidate.Score, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", score), 64)
-		allCandidates = append(allCandidates, candidate)
+		if targetScore > 0 {
+			if score >= targetScore {
+				candidate.Score, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", score), 64)
+				allCandidates = append(allCandidates, candidate)
+			}
+		} else {
+			candidate.Score, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", score), 64)
+			allCandidates = append(allCandidates, candidate)
+		}
 	}
 	}
 
 
 	// 排序(降序)
 	// 排序(降序)
@@ -211,16 +217,16 @@ func searchPrecise(client *elastic.Client, projectName, province, city, publish
 					queries = append(queries, query2)
 					queries = append(queries, query2)
 				}
 				}
 
 
-				// 3. 不限制省市
-				if province != "" {
-					query3 := elastic.NewBoolQuery()
-					query3 = query3.Must(elastic.NewMultiMatchQuery(projectName, field).Type("phrase"))
-					query3 = query3.Filter(filters...)
-					if !t.IsZero() {
-						query3 = query3.Must(elastic.NewRangeQuery("publishtime").Gte(dateRangeStart).Lt(dateRangeEnd))
-					}
-					queries = append(queries, query3)
-				}
+				//// 3. 不限制省市
+				//if province != "" {
+				//	query3 := elastic.NewBoolQuery()
+				//	query3 = query3.Must(elastic.NewMultiMatchQuery(projectName, field).Type("phrase"))
+				//	query3 = query3.Filter(filters...)
+				//	if !t.IsZero() {
+				//		query3 = query3.Must(elastic.NewRangeQuery("publishtime").Gte(dateRangeStart).Lt(dateRangeEnd))
+				//	}
+				//	queries = append(queries, query3)
+				//}
 			}
 			}
 
 
 			for _, query := range queries {
 			for _, query := range queries {
@@ -348,14 +354,14 @@ func searchByToken(client *elastic.Client, projectName, province, city, publish
 					}
 					}
 					queries = append(queries, q)
 					queries = append(queries, q)
 				}
 				}
-				// 无省市
-				q := elastic.NewBoolQuery().
-					Must(elastic.NewMatchQuery(field, queryText)).
-					Filter(filters...)
-				if !t.IsZero() {
-					q = q.Must(elastic.NewRangeQuery("publishtime").Gte(dateRangeStart).Lt(dateRangeEnd))
-				}
-				queries = append(queries, q)
+				//// 无省市
+				//q := elastic.NewBoolQuery().
+				//	Must(elastic.NewMatchQuery(field, queryText)).
+				//	Filter(filters...)
+				//if !t.IsZero() {
+				//	q = q.Must(elastic.NewRangeQuery("publishtime").Gte(dateRangeStart).Lt(dateRangeEnd))
+				//}
+				//queries = append(queries, q)
 			}
 			}
 
 
 			for _, query := range queries {
 			for _, query := range queries {
@@ -508,27 +514,27 @@ func searchCommon(client *elastic.Client, projectName, province, city, publish s
 				queries = append(queries, q)
 				queries = append(queries, q)
 			}
 			}
 
 
-			// 3. 不加省市
-			q := map[string]interface{}{
-				"bool": map[string]interface{}{
-					"must": []interface{}{
-						commonQuery(field, 0.2),
-					},
-				},
-			}
-			if !t.IsZero() {
-				q["bool"].(map[string]interface{})["filter"] = []interface{}{
-					map[string]interface{}{
-						"range": map[string]interface{}{
-							"publishtime": map[string]interface{}{
-								"gte": dateRangeStart,
-								"lt":  dateRangeEnd,
-							},
-						},
-					},
-				}
-			}
-			queries = append(queries, q)
+			//// 3. 不加省市
+			//q := map[string]interface{}{
+			//	"bool": map[string]interface{}{
+			//		"must": []interface{}{
+			//			commonQuery(field, 0.2),
+			//		},
+			//	},
+			//}
+			//if !t.IsZero() {
+			//	q["bool"].(map[string]interface{})["filter"] = []interface{}{
+			//		map[string]interface{}{
+			//			"range": map[string]interface{}{
+			//				"publishtime": map[string]interface{}{
+			//					"gte": dateRangeStart,
+			//					"lt":  dateRangeEnd,
+			//				},
+			//			},
+			//		},
+			//	}
+			//}
+			//queries = append(queries, q)
 		}
 		}
 
 
 		for _, q := range queries {
 		for _, q := range queries {

+ 2 - 2
project_chuan/project_test.go

@@ -153,7 +153,7 @@ func TestSearchProjectFullScoring(t *testing.T) {
 		publish := rows[i][5]
 		publish := rows[i][5]
 
 
 		fmt.Println(i, projectName)
 		fmt.Println(i, projectName)
-		res, err := SearchProjectFullScoring(client, target, projectName, areacode, publish)
+		res, err := SearchProjectFullScoring(client, target, projectName, areacode, publish, 80)
 		if err != nil {
 		if err != nil {
 			fmt.Println(err)
 			fmt.Println(err)
 		}
 		}
@@ -238,7 +238,7 @@ func TestSearchProjectFullScoring2(t *testing.T) {
 		publish := ""
 		publish := ""
 
 
 		fmt.Println(i, projectName)
 		fmt.Println(i, projectName)
-		res, err := SearchProjectFullScoring(client, target, projectName, areacode, publish)
+		res, err := SearchProjectFullScoring(client, target, projectName, areacode, publish, 80)
 		if err != nil {
 		if err != nil {
 			fmt.Println(err)
 			fmt.Println(err)
 		}
 		}

+ 33 - 0
updateBidding/bidding.go

@@ -450,3 +450,36 @@ func updateBiddingBuyer() {
 	}
 	}
 
 
 }
 }
+
+// deleteBiddingES  删除bidding数据
+func deleteBiddingES() {
+	defer util.Catch()
+	sess := MgoB.GetMgoConn()
+	defer MgoB.DestoryMongoConn(sess)
+
+	it := sess.DB("qfw").C("bidding_file_err").Find(nil).Select(nil).Iter()
+	count := 0
+
+	for tmp := make(map[string]interface{}); it.Next(&tmp); count++ {
+		if count%1000 == 0 {
+			log.Info("current", log.Int("count", count), log.Any("_id", tmp["_id"]))
+		}
+
+		biddingID := mongodb.BsonIdToSId(tmp["_id"])
+
+		// 更新Es 数据
+		if util.IntAll(tmp["extracttype"]) == -1 {
+			//2.es 项目 更新字段
+			err := Es.DeleteByID("bidding", biddingID)
+			err = EsNew.DeleteByID("bidding", biddingID)
+			err = EsNew.DeleteByID("bidding_temp", biddingID)
+			if err != nil && err.Error() != "Document not updated: noop" {
+				log.Info("bidding es update err", err, biddingID)
+			}
+
+		}
+
+	}
+
+	log.Info("DeleteBiddingES", zap.Any("数据处理完毕", count))
+}

BIN
updateBidding/deleteBiddingES


+ 13 - 13
updateBidding/main.go

@@ -41,13 +41,13 @@ var (
 
 
 func Init() {
 func Init() {
 	MgoB = &mongodb.MongodbSim{
 	MgoB = &mongodb.MongodbSim{
-		//MongodbAddr: "172.31.31.202:27081,172.20.45.128:27080",
-		MongodbAddr: "127.0.0.1:27083",
-		DbName:      "qfw",
-		Size:        10,
-		UserName:    "SJZY_RWbid_ES",
-		Password:    "SJZY@B4i4D5e6S",
-		Direct:      true,
+		MongodbAddr: "172.31.31.202:27081,172.20.45.128:27080",
+		//MongodbAddr: "127.0.0.1:27083",
+		DbName:   "qfw",
+		Size:     10,
+		UserName: "SJZY_RWbid_ES",
+		Password: "SJZY@B4i4D5e6S",
+		//Direct:      true,
 	}
 	}
 	MgoB.InitPool()
 	MgoB.InitPool()
 
 
@@ -106,8 +106,8 @@ func Init() {
 
 
 	//es
 	//es
 	Es = &elastic.Elastic{
 	Es = &elastic.Elastic{
-		S_esurl: "http://127.0.0.1:19908",
-		//S_esurl:  "http://172.17.4.184:19908",
+		//S_esurl: "http://127.0.0.1:19908",
+		S_esurl:  "http://172.17.4.184:19908",
 		I_size:   5,
 		I_size:   5,
 		Username: "jybid",
 		Username: "jybid",
 		Password: "Top2023_JEB01i@31",
 		Password: "Top2023_JEB01i@31",
@@ -116,8 +116,8 @@ func Init() {
 
 
 	//es 新集群
 	//es 新集群
 	EsNew = &elastic.Elastic{
 	EsNew = &elastic.Elastic{
-		S_esurl: "http://127.0.0.1:19905",
-		//S_esurl:  "http://172.17.4.184:19905",
+		//S_esurl: "http://127.0.0.1:19905",
+		S_esurl:  "http://172.17.4.184:19905",
 		I_size:   5,
 		I_size:   5,
 		Username: "jybid",
 		Username: "jybid",
 		Password: "Top2023_JEB01i@31",
 		Password: "Top2023_JEB01i@31",
@@ -129,8 +129,8 @@ func main() {
 	//updatePing()
 	//updatePing()
 	//return
 	//return
 	Init()
 	Init()
-
-	updateBiddingBuyer()
+	deleteBiddingES()
+	//updateBiddingBuyer()
 
 
 	return
 	return
 	//InitEsBiddingField()
 	//InitEsBiddingField()