Bläddra i källkod

fix:搜索置顶功能修改与数据导出查询修改

duxin 3 år sedan
förälder
incheckning
6b8e965502

+ 3 - 3
src/jfw/front/supsearch.go

@@ -396,7 +396,8 @@ func Newbids(p string) []interface{} {
 		intns := make([]int, 0)
 		for i := 0; i < 10; i++ {
 			if len(intns) == 0 {
-				intns = append(intns, rand.Intn(100))
+				//			intns = append(intns, rand.Intn(100))
+				intns = append(intns, 0)
 			} else {
 				for {
 					v := rand.Intn(intns[(i-1)] + 100)
@@ -407,14 +408,13 @@ func Newbids(p string) []interface{} {
 				}
 			}
 		}
-
 		for i := 0; i < 10; i++ {
 			_, list = getLastNewsData("", "", "", "", subtype, "", "", "", "", "", "", "", "Y", intns[i], true, false, "")
 			for k, v := range *list {
 				v["k"] = (k + 1) + i*50
 				t := time.Unix(util.Int64All(v["publishtime"]), 0)
 				v["timetemp"] = fmt.Sprint(util.Int64All(v["publishtime"]))
-				v["_id"] = util.EncodeArticleId2ByCheck(v["_id"].(string))
+				v["_id"] = util.EncodeArticleId2ByCheck(util.InterfaceToStr(v["_id"]))
 				v["time"] = util.TimeDiff(t)
 				var stp = ""
 				if v["subtype"] != nil {

+ 2 - 2
src/jfw/front/swordfish.go

@@ -33,9 +33,9 @@ import (
 )
 
 var (
-	bidSearch_field_1    = `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","bidamount","budget","buyerclass","spidercode","site"`
+	bidSearch_field_1    = `"_id","title","publishtime","toptype","subtype","type","area","dataweight","city","s_subscopeclass","bidamount","budget","buyerclass","spidercode","site"`
 	bidSearch_field      = bidSearch_field_1 + `,"bidopentime","winner","buyer","projectname","projectcode","projectinfo"`
-	bidSearch_sort       = `{"publishtime":-1}`
+	bidSearch_sort       = `{"_score":-1,"publishtime":-1}`
 	bidSearch_field_file = `,"filetext","isValidFile"`
 )
 

+ 3 - 2
src/jfw/modules/common/src/qfw/util/bidsearch/search.go

@@ -18,7 +18,7 @@ import (
 const (
 	INDEX          = "bidding"
 	TYPE           = "bidding"
-	bidSearch_sort = `{"dataweight":-1,"publishtime":-1}`
+	bidSearch_sort = `{"_score":-1,"publishtime":-1}`
 
 	//招标搜索分页--每页显示数量
 	SearchPageSize_APP = 50
@@ -248,7 +248,8 @@ func DetailTitle(findfields string) bool {
 }
 func GetSearchQuery(keyword, industry, minprice, maxprice, hasBuyerTel, hasWinnerTel, fileExists, findfields, mustquery, notkey string, searchTypeSwitch bool) (qstr string) {
 	multi_match := `{"multi_match": {"query": "%s","type": "phrase", "fields": [%s]}}`
-	query := `{"query":{"bool":{"must":[%s],"must_not":[%s]}}}`
+	//query := `{"query":{"bool":{"must":[%s],"must_not":[%s]}}}`
+	query := `{"query": {"function_score": {"query": {"bool": {"must": [%s],"must_not": [%s]}},"field_value_factor": {"field": "dataweight","modifier": "ln1p","missing": 0}}}}`
 	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 	query_bools_must := `{"bool":{"must":[{"range":{"bidamount":{%s}}}]}},{"bool":{"must":[{"range":{"budget":{%s}}}],"must_not":[{"range":{"bidamount":{"gte":-1}}}]}}`
 	query_bool_must := `{"bool":{"must":[{"terms":{"s_subscopeclass":[%s]}}]}}`

+ 3 - 2
src/jfw/modules/common/src/qfw/util/dataexport/dataexport.go

@@ -91,7 +91,8 @@ func getDataExportSql(scd *SieveCondition) string {
 		return fmt.Sprintf(query, doSearchSql)
 	}
 	multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
-	query := `{"query":{"bool":{"must":[%s],"must_not":[%s],"should":[%s],"minimum_should_match": %d}}}`
+	//query := `{"query":{"bool":{"must":[%s],"must_not":[%s],"should":[%s],"minimum_should_match": %d}}}`
+	query := `{"query": {"function_score": {"query": {"bool": {"must": [%s],"must_not": [%s],"should": [%s],"minimum_should_match": %d}},"field_value_factor": {"field": "dataweight","modifier": "ln1p","missing": 0}}}}`
 	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 	query_price := `{"bool":{"must":[{"range":{"bidamount":{%s}}}]}},{"bool":{"must":[{"range":{"budget":{%s}}}],"must_not":[{"range":{"bidamount":{"gte":-1}}}]}}`
 	query_bool_must := `{"terms":{"%s":[%s]}}`
@@ -918,7 +919,7 @@ func doSearch(sql string, start, count int, dataType string) *[]map[string]inter
 			sql = sql[:len(sql)-1] + `,"_source":[` + dataexport_field + "]}"
 		}
 		//分页排序
-		sql = sql[:len(sql)-1] + `,"sort": {"publishtime":"desc","id":"desc"},"from":` + strconv.Itoa(start) + `,"size":` + strconv.Itoa(count) + "}"
+		sql = sql[:len(sql)-1] + `,"sort": {"_score": "desc","publishtime":"desc","id":"desc"},"from":` + strconv.Itoa(start) + `,"size":` + strconv.Itoa(count) + "}"
 	}
 	log.Println("doSearch", sql)
 	return elastic.Get(INDEX, TYPE, sql)