Browse Source

排序处理

WH01243 7 months ago
parent
commit
e80b4c4e37
1 changed files with 8 additions and 3 deletions
  1. 8 3
      jyBXCore/rpc/service/operator.go

+ 8 - 3
jyBXCore/rpc/service/operator.go

@@ -510,7 +510,7 @@ func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
 		start = 0
 	}
 	var query = `{"query":{"bool":{"must":[%s],"filter":[%s],"minimum_should_match":1,
-	"should":[{"exists":{"field":"bidamount"}},{"bool":{"should":[{"exists":{"field":"budget"}},{"bool":{"must_not":[{"exists":{"field":"budget"}}]}}],"must_not":[{"exists":{"field":"bidamount"}}]}}]}},"from":"%d","size":"%d","sort":[{"publishtime":{"order":"%s"}}]
+	"should":[{"exists":{"field":"bidamount"}},{"bool":{"should":[{"exists":{"field":"budget"}},{"bool":{"must_not":[{"exists":{"field":"budget"}}]}}],"must_not":[{"exists":{"field":"bidamount"}}]}}]}},"from":"%d","size":"%d","sort":[{"publishtime":{"order":"%s"}}%s]
 	}`
 	shouldStr := `{"bool":{"should":[%s]}}`
 	mustArr := []string{}
@@ -552,7 +552,7 @@ func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
 			}
 			if k == 1 {
 				if v != "" {
-					filterArr = append(filterArr, fmt.Sprint(`{"range":{"publishtime":{"lt":"%d"}}}`, v))
+					filterArr = append(filterArr, fmt.Sprint(`{"range":{"expurasingtime":{"lt":"%d"}}}`, v))
 				}
 			}
 		}
@@ -783,7 +783,12 @@ func SearchList(operator Operator) (int64, *[]map[string]interface{}) {
 	if operator.Order == "" {
 		operator.Order = "desc"
 	}
-	queryStr := fmt.Sprintf(query, strings.Join(mustArr, ","), strings.Join(filterArr, ","), start, operator.PageSize, operator.Order)
+	queryStr := ""
+	if operator.Tag == 1 {
+		queryStr = fmt.Sprintf(query, strings.Join(mustArr, ","), strings.Join(filterArr, ","), start, operator.PageSize, operator.Order, `,{"expurasingtime":{"order":"asc"}}`)
+	} else if operator.Tag == 2 {
+		queryStr = fmt.Sprintf(query, strings.Join(mustArr, ","), strings.Join(filterArr, ","), start, operator.PageSize, operator.Order, `,{"bidopentime":{"order":"asc"}}`)
+	}
 	fmt.Println(queryStr)
 	start1 := time.Now().Unix()
 	fmt.Println(start1)