Browse Source

feat:es不兼容语句修改

wangchuanjin 2 years ago
parent
commit
a144b52581
1 changed files with 6 additions and 2 deletions
  1. 6 2
      jyBXBase/rpc/model/newestBidding.go

+ 6 - 2
jyBXBase/rpc/model/newestBidding.go

@@ -25,7 +25,7 @@ const (
 	query_bool_must     = `{"terms":{"%s":[%s]}}`
 	query_bool_must_and = `{"bool":{"must":[%s],"must_not":[%s]}}`
 	search_field        = `"_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","isValidFile","spidercode","site"`
-	query_city_hkeys    = `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": 1}},"highlight": {"pre_tags": ["<a>"],"post_tags": ["</a>"],"fields": {"title": {"fragment_size": 0,"number_of_fragments": 1}}},"_source":[` + search_field + `],"sort":[{"publishtime":"desc"},{"budget":"desc"}],"from":0,"size":50}`
+	query_city_hkeys    = `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match":%d}},"highlight": {"pre_tags": ["<a>"],"post_tags": ["</a>"],"fields": {"title": {"fragment_size": 0,"number_of_fragments": 1}}},"_source":[` + search_field + `],"sort":[{"publishtime":"desc"},{"budget":"desc"}],"from":0,"size":50}`
 	Pushbidding         = "global_common_data.dws_f_bid_baseinfo"
 	Province            = "province"
 )
@@ -176,7 +176,11 @@ func NewestQuery(city, keys, subtype string) (str string) {
 	if subtype != "" {
 		musts = append(musts, fmt.Sprintf(query_bool_must, "subtype", subtype))
 	}
-	str = fmt.Sprintf(query_city_hkeys, strings.Join(musts, ","), strings.Join(bools, ","))
+	minimum_should_match := 0
+	if len(bools) > 0 {
+		minimum_should_match = 1
+	}
+	str = fmt.Sprintf(query_city_hkeys, strings.Join(musts, ","), strings.Join(bools, ","), minimum_should_match)
 	logx.Info("str:", str)
 	return
 }