Commit 3ea7aee3 by mushishixian

参数匹配型号

parent 3e477f1e
......@@ -22,7 +22,7 @@ func init() {
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//}
//
//str := `{"bom_id":523,"delivery_type":1,"sort":1}`
//str := `{"bom_id":530,"delivery_type":1,"sort":1}`
//rabbitmq.Send(queueExchange, str)
}
......
......@@ -58,7 +58,6 @@ func MatchGoodsNameByAttrs(bomItems []model.BomItem) (result []model.BomItem, er
res, _ := hit.Source.MarshalJSON()
//还要去判断至少符合特定数量参数匹配的结果,比如最小匹配参数为2,那就是要有两个参数匹配到才正确
bomItems[key].GoodsName = gjson.Get(string(res), "goods_name").String()
//fmt.Println(string(res))
}
}
}
......
......@@ -228,16 +228,13 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
if !rawSearch {
bom.GoodsName = common.SubKeyWordStr(bom.GoodsName)
}
if bom.GoodsName == "" {
continue
}
//经过了最前面的参数匹配
//如果型号还是为空,则用参数去匹配,因为有可能参数里面填了型号
//if bom.GoodsName == "" && bom.Attrs == "" {
// continue
//} else if bom.GoodsName == "" && bom.Attrs != "" {
// bom.GoodsName = bom.Attrs
//}
if bom.GoodsName == "" && bom.Attrs == "" {
continue
} else if bom.GoodsName == "" && bom.Attrs != "" {
bom.GoodsName = bom.Attrs
}
//构建一个goods_name对应的bomItems列表
searchRequest := getSearchParams(index, bom.GoodsName, bom.BrandName, sort, bom.Number, rawSearch)
searchFlag = true
......@@ -294,11 +291,6 @@ func getSearchParams(index, goodsName, brandName string, sort, number int, flag
}
//要去判断sort,sort=2是按照价格排序
if sort == 2 {
//if index != "liexin_ziying" {
// source.Sort("single_price_sort", false)
//}
//source.Sort("single_price_sort", false)
//source.Sort("stock", false)
source.Sort("single_price", true)
//sort=3是按照库存排序
} else if sort == 3 {
......@@ -308,7 +300,6 @@ func getSearchParams(index, goodsName, brandName string, sort, number int, flag
source.Sort("_score", false)
source = source.From(0).Size(1)
searchRequest = es.NewSearchRequest().Source(source)
//fmt.Println(searchRequest.Body())
return searchRequest
}
......
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