Commit ce726eaf by mushishixian

修改协程数量

parent 232bb276
......@@ -28,7 +28,7 @@ func GetStandardAttrs(bomItems []model.BomItem) []model.BomItem {
}
params := req.BodyJSON(attrParams)
resp, err := req.Post(configs.ApiSetting.Attrs, params)
fmt.Println(resp)
//fmt.Println(resp)
if err != nil {
fmt.Println(err)
}
......
......@@ -30,7 +30,7 @@ func MatchGoods(message model.BomMessage) (err error) {
if configs.ApiSetting.Mode == "debug" {
perGoDealNumber = 200
} else {
perGoDealNumber = 40
perGoDealNumber = 20
}
//开启协程处理搜索
var wg sync.WaitGroup
......
......@@ -6,7 +6,6 @@ import (
"bom_server/internal/model"
"context"
"encoding/json"
"fmt"
es "gopkg.in/olivere/elastic.v5"
"regexp"
"strings"
......@@ -101,7 +100,7 @@ func getSearchParams(index string, bomItem model.BomItem, sort int, flag bool) (
}
source = source.From(0).Size(1)
searchRequest = es.NewSearchRequest().Source(source)
fmt.Println(searchRequest.Body())
//fmt.Println(searchRequest.Body())
return searchRequest
}
......@@ -116,6 +115,7 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
//用于判断下面的miniShould,因为下面的参数里面,如果出现阻值的,用的是should语句
//为了保证所有参数都必须参与搜索,所以要用miniShould去做限制
//var shouldNumber int
var hasSpecialQuery bool
//商品名称太短的或者没有商品名称的,去搜索参数
if len(goodsName) <= 3 {
if len(bomItem.AttrList) > 0 {
......@@ -131,13 +131,16 @@ func getTermQuery(bomItem model.BomItem, sort int, flag bool) (query *es.BoolQue
}
//需要注意的点 : 因为0.158Ω可以对应 电阻 或者 直流电阻 ,所以当识别出来是电阻 或者 直流电阻 的时候,就不能用must,要用should
if strings.Contains(attr, "ZLNZ€") || strings.Contains(attr, "OM€") {
hasSpecialQuery = true
//query.Should(es.NewTermQuery("attr_bom", attr))
q.Should(es.NewTermQuery("attr_bom", attr))
} else {
query.Must(es.NewTermQuery("attr_bom", attr))
}
}
query.Must(q)
if hasSpecialQuery {
query.Must(q)
}
} else {
query = query.Must(es.NewTermsQuery("attr_bom", "$_$"))
}
......
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