修复状态问题

parent 192071e0
Showing with 11 additions and 10 deletions
......@@ -10,7 +10,7 @@ import (
"strings"
)
func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sort int, client *es.Client, rawSearch bool,isAlike bool) (goodsMapList []GoodsMap, err error) {
func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sort int, client *es.Client, rawSearch bool, isAlike bool) (goodsMapList []GoodsMap, err error) {
//先去自营查一遍
search := client.MultiSearch().Index(index)
//是否已经搜索过标签
......@@ -32,10 +32,10 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
paramsRawSearch = true
}
//构建一个goods_name对应的bomItems列表
searchRequest := getSearchParams(index, bom, sort, paramsRawSearch,rawSearch,isAlike)
searchRequest := getSearchParams(index, bom, sort, paramsRawSearch, rawSearch, isAlike)
searchFlag = true
common.PrintDebug("查询es索引,","是否原生rawSearch:",rawSearch," 是否类似:",isAlike,index)
common.PrintDebug("查询es索引,", "是否原生rawSearch:", rawSearch, " 是否类似:", isAlike, index)
common.PrintDebug(searchRequest.Body())
//randInt := rand.Intn(10)
......@@ -50,7 +50,6 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
common.PrintDebug(res.Responses)
if err != nil {
return
}
......@@ -83,16 +82,18 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
}
}
}
common.PrintDebug("search end")
return
}
//构建请求参数
func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool,rawSearch bool,isAlike bool) (searchRequest *es.SearchRequest) {
func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool, rawSearch bool, isAlike bool) (searchRequest *es.SearchRequest) {
//fmt.Println("商品名称 : ", bomItem.GoodsName)
//fmt.Println("参数列表 : ", bomItem.AttrList)
bomItem.Encap = TransformEncap(bomItem.Encap)
//fmt.Println("封装 : ", bomItem.Encap)
query := getTermQuery(bomItem, sort, flag,rawSearch,isAlike)
query := getTermQuery(bomItem, sort, flag, rawSearch, isAlike)
source := es.NewSearchSource().Query(query)
if sort == 1 {
//source.Sort("_score", false)
......@@ -114,7 +115,7 @@ func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool,ra
}
//构建term条件
func getTermQuery(bomItem model.BomItem, sort int, flag bool,rawSearch bool,isAlike bool) (query *es.BoolQuery) {
func getTermQuery(bomItem model.BomItem, sort int, flag bool, rawSearch bool, isAlike bool) (query *es.BoolQuery) {
query = es.NewBoolQuery()
goodsName := common.DrawLetterNum(bomItem.GoodsName)
if flag {
......@@ -169,7 +170,7 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool,rawSearch bool,isAl
//精确匹配
if rawSearch {
query = query.Must(es.NewRangeQuery("stock").Gte(bomItem.Number * bomItem.Amount)) //搜索库存
}else{
} else {
query = query.Should(es.NewRangeQuery("stock").Gte(bomItem.Number * bomItem.Amount)) //搜索库存
}
......@@ -179,7 +180,7 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool,rawSearch bool,isAl
query = query.Must(es.NewTermQuery("goods_name", goodsName))
}
common.PrintDebug("isalike:",isAlike)
common.PrintDebug("isalike:", isAlike)
//只显示库存大于0的数据
if rawSearch == false { //不是精确匹配
query.Must(es.NewRangeQuery("stock").Gt(0))
......@@ -190,7 +191,7 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool,rawSearch bool,isAl
// query = query.Filter(es.NewRangeQuery("single_price").Gt(0))
//}
//只显示起订量大于0
query.Must(es.NewRangeQuery("moq").Gt(0).Lte(bomItem.Number*bomItem.Amount)) //todo 2021.4.17 起订量高于需求数量的排除;
query.Must(es.NewRangeQuery("moq").Gt(0).Lte(bomItem.Number * bomItem.Amount)) //todo 2021.4.17 起订量高于需求数量的排除;
if configs.ApiSetting.Mode != "debug" {
query = query.Filter(es.NewTermQuery("status", 1))
......
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