Commit 7fe143a7 by 孙龙

up

parent 7adf944a
Showing with 33 additions and 1 deletions
......@@ -217,15 +217,47 @@ func searchZiYingGoods( req map[string]string,zy bool,classList *model.ZhyClassL
}
//库存排序
if stock_rank,ok :=req["stock_rank"];ok && stock_rank != "" {
switch {
case strings.TrimSpace(stock_rank) == "1":
source.Sort("stock",true) //desc
case strings.TrimSpace(stock_rank) == "2":
source.Sort("stock",false) //asc
}
}
//综合排序
if com_rank,ok :=req["com_rank"];ok && strings.TrimSpace(com_rank) == "1" {
source.Sort("sort",true) //desc
source.Sort("single_price",false) //asc
}
}
length := int64(10)
if offset,ok := req["offset"];ok {
if offsetInt,err:=strconv.ParseInt(offset, 10, 64); err != nil && offsetInt > 0{
length = offsetInt
}
}
page := int64(1)
if p,ok := req["p"];ok {
if pInt,err:=strconv.ParseInt(p, 10, 64); err != nil && pInt > 0{
page = pInt
}
}
start := (page-1)*length
from := start
if start+length >= 10000 {
from = 10000-length
}
source.From(int(from)).Size(int(length))
source.Query(query)
res,_ := elastic.NewSearchRequest().Source(source).Body()
fmt.Println(res)
}
func makeQuery(query *elastic.BoolQuery,source *elastic.SearchSource,conditions []string,goods_temp_status *int,searchValue *string,keyword *string,is_sample *bool) bool{
func makeQuery(query *elastic.BoolQuery,source *elastic.SearchSource,conditions []string,goods_temp_status *int,searchValue *string,
keyword *string,is_sample *bool) bool{
var (
err error
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment