Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
47163d07
authored
Jun 28, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://119.23.72.7/mushishixian/search_server
parents
7e638973
fbd773ab
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
176 additions
and
51 deletions
cmd/search_http_server.go
conf/config_production.ini
controller/middleware_controller.go
doc/bom_service.md
go.mod
protopb/bom/bom.pb.go
protos/bom.proto
service/attr_service.go
service/bom_service.go
cmd/search_http_server.go
View file @
47163d07
...
...
@@ -12,7 +12,7 @@ import (
func
main
()
{
var
path
string
flag
.
StringVar
(
&
path
,
"config"
,
"
../
conf/config.ini"
,
"配置文件"
)
flag
.
StringVar
(
&
path
,
"config"
,
"conf/config.ini"
,
"配置文件"
)
flag
.
Parse
()
if
err
:=
boot
.
Boot
(
path
);
err
!=
nil
{
panic
(
err
)
...
...
conf/config_production.ini
View file @
47163d07
[web]
port
=
9000
port
=
20001
mode
=
release
cors_domain
=
bom.ichunt.com
...
...
@@ -12,7 +12,7 @@ api_url = http://47.106.60.211:60004
[es]
url
=
http://172.18.137.29:9211
urls
=
http://172.18.137.29:9211,172.18.137.30:9211
urls
=
http://172.18.137.29:9211,
http://
172.18.137.30:9211
index_name
=
future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
search_supplier
=
future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin,zhuanmai
hk_delivery_type_supplier
=
future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
...
...
controller/middleware_controller.go
View file @
47163d07
...
...
@@ -26,7 +26,7 @@ func Cors_Middleware() gin_.Middleware {
for
_
,
domain
:=
range
corsDomains
{
c
.
Header
(
"Access-Control-Allow-Origin"
,
domain
)
}
c
.
Header
(
"Access-Control-Allow-Origin"
,
"http
://bom.liexin
.com"
)
c
.
Header
(
"Access-Control-Allow-Origin"
,
"http
s://bom.ichunt
.com"
)
c
.
Header
(
"Access-Control-Allow-Headers"
,
"Content-Type,AccessToken,X-CSRF-Token, Authorization, Token"
)
c
.
Header
(
"Access-Control-Allow-Methods"
,
"POST, GET, OPTIONS"
)
c
.
Header
(
"Access-Control-Expose-Headers"
,
"Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type"
)
...
...
doc/bom_service.md
0 → 100644
View file @
47163d07
##bom_service 实现了bom的搜索
go.mod
View file @
47163d07
...
...
@@ -16,7 +16,9 @@ require (
github.com/ichunt2019/logger v1.0.5
github.com/imroc/req v0.3.0
github.com/jinzhu/gorm v1.9.12
github.com/micro/go-micro/v2 v2.5.0
github.com/joncalhoun/qson v0.0.0-20170526102502-8a9cab3a62b1 // indirect
github.com/mholt/certmagic v0.9.3 // indirect
github.com/micro/go-micro/v2 v2.9.0
github.com/prometheus/client_golang v1.5.1 // indirect
github.com/prometheus/common v0.10.0
github.com/prometheus/procfs v0.0.11 // indirect
...
...
@@ -33,6 +35,7 @@ require (
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/olivere/elastic.v5 v5.0.85
gopkg.in/src-d/go-git.v4 v4.13.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
...
...
protopb/bom/bom.pb.go
View file @
47163d07
...
...
@@ -431,50 +431,84 @@ func (m *LadderPrice) GetPriceAc() float32 {
}
type
GoodsModel
struct
{
OtherAttrs
*
OtherAttrs
`protobuf:"bytes,1,opt,name=other_attrs,json=otherAttrs,proto3" json:"other_attrs,omitempty"`
PickType
int64
`protobuf:"varint,2,opt,name=pick_type,json=pickType,proto3" json:"pick_type,omitempty"`
Barcode
string
`protobuf:"bytes,3,opt,name=barcode,proto3" json:"barcode,omitempty"`
GoodsId
string
`protobuf:"bytes,4,opt,name=goods_id,json=goodsId,proto3" json:"goods_id,omitempty"`
GoodsType
int64
`protobuf:"varint,5,opt,name=goods_type,json=goodsType,proto3" json:"goods_type,omitempty"`
SupplierId
int64
`protobuf:"varint,6,opt,name=supplier_id,json=supplierId,proto3" json:"supplier_id,omitempty"`
BrandId
int64
`protobuf:"varint,7,opt,name=brand_id,json=brandId,proto3" json:"brand_id,omitempty"`
ClassId1
int64
`protobuf:"varint,8,opt,name=class_id1,json=classId1,proto3" json:"class_id1,omitempty"`
ClassId2
int64
`protobuf:"varint,9,opt,name=class_id2,json=classId2,proto3" json:"class_id2,omitempty"`
GoodsName
string
`protobuf:"bytes,10,opt,name=goods_name,json=goodsName,proto3" json:"goods_name,omitempty"`
Status
int64
`protobuf:"varint,11,opt,name=status,proto3" json:"status,omitempty"`
Encoded
string
`protobuf:"bytes,12,opt,name=encoded,proto3" json:"encoded,omitempty"`
Encap
string
`protobuf:"bytes,13,opt,name=encap,proto3" json:"encap,omitempty"`
Packing
int64
`protobuf:"varint,14,opt,name=packing,proto3" json:"packing,omitempty"`
GoodsUnit
int64
`protobuf:"varint,15,opt,name=goods_unit,json=goodsUnit,proto3" json:"goods_unit,omitempty"`
GoodsImages
bool
`protobuf:"varint,16,opt,name=goods_images,json=goodsImages,proto3" json:"goods_images,omitempty"`
Pdf
string
`protobuf:"bytes,17,opt,name=pdf,proto3" json:"pdf,omitempty"`
GoodsBrief
string
`protobuf:"bytes,18,opt,name=goods_brief,json=goodsBrief,proto3" json:"goods_brief,omitempty"`
Moq
int64
`protobuf:"varint,19,opt,name=moq,proto3" json:"moq,omitempty"`
Mpq
int64
`protobuf:"varint,20,opt,name=mpq,proto3" json:"mpq,omitempty"`
// @inject_tag: json:"other_attrs"
OtherAttrs
*
OtherAttrs
`protobuf:"bytes,1,opt,name=other_attrs,json=otherAttrs,proto3" json:"other_attrs"`
// @inject_tag: json:"pick_type"
PickType
int64
`protobuf:"varint,2,opt,name=pick_type,json=pickType,proto3" json:"pick_type"`
// @inject_tag: json:"barcode"
Barcode
string
`protobuf:"bytes,3,opt,name=barcode,proto3" json:"barcode"`
// @inject_tag: json:"goods_id"
GoodsId
string
`protobuf:"bytes,4,opt,name=goods_id,json=goodsId,proto3" json:"goods_id"`
// @inject_tag: json:"goods_type
GoodsType
int64
`protobuf:"varint,5,opt,name=goods_type,json=goodsType,proto3" json:"goods_type,omitempty"`
// @inject_tag: json:"supplier_id"
SupplierId
int64
`protobuf:"varint,6,opt,name=supplier_id,json=supplierId,proto3" json:"supplier_id"`
// @inject_tag: json:"brand_id"
BrandId
int64
`protobuf:"varint,7,opt,name=brand_id,json=brandId,proto3" json:"brand_id"`
// @inject_tag: json:"class_id1"
ClassId1
int64
`protobuf:"varint,8,opt,name=class_id1,json=classId1,proto3" json:"class_id1"`
// @inject_tag: json:"class_id2"
ClassId2
int64
`protobuf:"varint,9,opt,name=class_id2,json=classId2,proto3" json:"class_id2"`
// @inject_tag: json:"goods_name"
GoodsName
string
`protobuf:"bytes,10,opt,name=goods_name,json=goodsName,proto3" json:"goods_name"`
// @inject_tag: json:"status"
Status
int64
`protobuf:"varint,11,opt,name=status,proto3" json:"status"`
// @inject_tag: json:"encoded"
Encoded
string
`protobuf:"bytes,12,opt,name=encoded,proto3" json:"encoded"`
// @inject_tag: json:"encap"
Encap
string
`protobuf:"bytes,13,opt,name=encap,proto3" json:"encap"`
// @inject_tag: json:"packing"
Packing
int64
`protobuf:"varint,14,opt,name=packing,proto3" json:"packing"`
// @inject_tag: json:"goods_unit"
GoodsUnit
int64
`protobuf:"varint,15,opt,name=goods_unit,json=goodsUnit,proto3" json:"goods_unit"`
// @inject_tag: json:"goods_images"
GoodsImages
bool
`protobuf:"varint,16,opt,name=goods_images,json=goodsImages,proto3" json:"goods_images"`
// @inject_tag: json:"pdf"
Pdf
string
`protobuf:"bytes,17,opt,name=pdf,proto3" json:"pdf"`
// @inject_tag: json:"goods_brief"
GoodsBrief
string
`protobuf:"bytes,18,opt,name=goods_brief,json=goodsBrief,proto3" json:"goods_brief"`
// @inject_tag: json:"moq"
Moq
int64
`protobuf:"varint,19,opt,name=moq,proto3" json:"moq"`
// @inject_tag: json:"mpq"
Mpq
int64
`protobuf:"varint,20,opt,name=mpq,proto3" json:"mpq"`
// @inject_tag: json:"ladder_price"
LadderPrice
[]
*
LadderPrice
`protobuf:"bytes,21,rep,name=ladder_price,json=ladderPrice,proto3" json:"ladder_price"`
UpdateTime
int64
`protobuf:"varint,22,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty"`
SkuName
string
`protobuf:"bytes,23,opt,name=sku_name,json=skuName,proto3" json:"sku_name,omitempty"`
Mpl
int64
`protobuf:"varint,24,opt,name=mpl,proto3" json:"mpl,omitempty"`
Stock
int64
`protobuf:"varint,25,opt,name=stock,proto3" json:"stock,omitempty"`
Attrs
string
`protobuf:"bytes,26,opt,name=attrs,proto3" json:"attrs,omitempty"`
Cost
string
`protobuf:"bytes,27,opt,name=cost,proto3" json:"cost,omitempty"`
NewCost
string
`protobuf:"bytes,28,opt,name=new_cost,json=newCost,proto3" json:"new_cost,omitempty"`
SupplierStock
int64
`protobuf:"varint,29,opt,name=supplier_stock,json=supplierStock,proto3" json:"supplier_stock,omitempty"`
SelfSupplierType
int64
`protobuf:"varint,30,opt,name=self_supplier_type,json=selfSupplierType,proto3" json:"self_supplier_type,omitempty"`
LadderPrice
[]
*
LadderPrice
`protobuf:"bytes,21,rep,name=ladder_price,json=ladderPrice,proto3" json:"ladder_price"`
// @inject_tag: json:"update_time"
UpdateTime
int64
`protobuf:"varint,22,opt,name=update_time,json=updateTime,proto3" json:"update_time"`
// @inject_tag: json:"sku_name"
SkuName
string
`protobuf:"bytes,23,opt,name=sku_name,json=skuName,proto3" json:"sku_name"`
// @inject_tag: json:"mpl"
Mpl
int64
`protobuf:"varint,24,opt,name=mpl,proto3" json:"mpl"`
// @inject_tag: json:"stock"
Stock
int64
`protobuf:"varint,25,opt,name=stock,proto3" json:"stock"`
// @inject_tag: json:"attrs"
Attrs
string
`protobuf:"bytes,26,opt,name=attrs,proto3" json:"attrs"`
// @inject_tag: json:"cost"
Cost
string
`protobuf:"bytes,27,opt,name=cost,proto3" json:"cost"`
// @inject_tag: json:"new_cost"
NewCost
string
`protobuf:"bytes,28,opt,name=new_cost,json=newCost,proto3" json:"new_cost"`
// @inject_tag: json:"supplier_stock"
SupplierStock
int64
`protobuf:"varint,29,opt,name=supplier_stock,json=supplierStock,proto3" json:"supplier_stock"`
// @inject_tag: json:"self_supplier_type"
SelfSupplierType
int64
`protobuf:"varint,30,opt,name=self_supplier_type,json=selfSupplierType,proto3" json:"self_supplier_type"`
// @inject_tag: json:"cn_delivery_time"
CnDeliveryTime
string
`protobuf:"bytes,31,opt,name=cn_delivery_time,json=cnDeliveryTime,proto3" json:"cn_delivery_time"`
BrandName
string
`protobuf:"bytes,32,opt,name=brand_name,json=brandName,proto3" json:"brand_name,omitempty"`
SupplierName
string
`protobuf:"bytes,33,opt,name=supplier_name,json=supplierName,proto3" json:"supplier_name,omitempty"`
GoodsUnitName
string
`protobuf:"bytes,34,opt,name=goods_unit_name,json=goodsUnitName,proto3" json:"goods_unit_name,omitempty"`
PackingName
string
`protobuf:"bytes,35,opt,name=packing_name,json=packingName,proto3" json:"packing_name,omitempty"`
MpqUnitName
string
`protobuf:"bytes,36,opt,name=mpq_unit_name,json=mpqUnitName,proto3" json:"mpq_unit_name,omitempty"`
AcType
int64
`protobuf:"varint,37,opt,name=ac_type,json=acType,proto3" json:"ac_type,omitempty"`
AllowCoupon
int64
`protobuf:"varint,38,opt,name=allow_coupon,json=allowCoupon,proto3" json:"allow_coupon,omitempty"`
ClassId1Name
string
`protobuf:"bytes,39,opt,name=class_id1_name,json=classId1Name,proto3" json:"class_id1_name,omitempty"`
ClassId2Name
string
`protobuf:"bytes,40,opt,name=class_id2_name,json=classId2Name,proto3" json:"class_id2_name,omitempty"`
IsBuy
int64
`protobuf:"varint,41,opt,name=is_buy,json=isBuy,proto3" json:"is_buy,omitempty"`
HkDeliveryType
string
`protobuf:"bytes,42,opt,name=hk_delivery_type,json=hkDeliveryType,proto3" json:"hk_delivery_type,omitempty"`
CnDeliveryTime
string
`protobuf:"bytes,31,opt,name=cn_delivery_time,json=cnDeliveryTime,proto3" json:"cn_delivery_time"`
// @inject_tag: json:"brand_name"
BrandName
string
`protobuf:"bytes,32,opt,name=brand_name,json=brandName,proto3" json:"brand_name"`
// @inject_tag: json:"supplier_name"
SupplierName
string
`protobuf:"bytes,33,opt,name=supplier_name,json=supplierName,proto3" json:"supplier_name"`
GoodsUnitName
string
`protobuf:"bytes,34,opt,name=goods_unit_name,json=goodsUnitName,proto3" json:"goods_unit_name,omitempty"`
PackingName
string
`protobuf:"bytes,35,opt,name=packing_name,json=packingName,proto3" json:"packing_name,omitempty"`
MpqUnitName
string
`protobuf:"bytes,36,opt,name=mpq_unit_name,json=mpqUnitName,proto3" json:"mpq_unit_name,omitempty"`
// @inject_tag: json:"ac_type"
AcType
int64
`protobuf:"varint,37,opt,name=ac_type,json=acType,proto3" json:"ac_type"`
AllowCoupon
int64
`protobuf:"varint,38,opt,name=allow_coupon,json=allowCoupon,proto3" json:"allow_coupon,omitempty"`
ClassId1Name
string
`protobuf:"bytes,39,opt,name=class_id1_name,json=classId1Name,proto3" json:"class_id1_name,omitempty"`
ClassId2Name
string
`protobuf:"bytes,40,opt,name=class_id2_name,json=classId2Name,proto3" json:"class_id2_name,omitempty"`
// @inject_tag: json:"otheis_buyr_attrs"
IsBuy
int64
`protobuf:"varint,41,opt,name=is_buy,json=isBuy,proto3" json:"otheis_buyr_attrs"`
// @inject_tag: json:"hk_delivery_type"
HkDeliveryType
string
`protobuf:"bytes,42,opt,name=hk_delivery_type,json=hkDeliveryType,proto3" json:"hk_delivery_type"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
...
...
protos/bom.proto
View file @
47163d07
...
...
@@ -68,48 +68,82 @@ message LadderPrice {
}
message
GoodsModel
{
// @inject_tag: json:"other_attrs"
OtherAttrs
other_attrs
=
1
;
// @inject_tag: json:"pick_type"
int64
pick_type
=
2
;
// @inject_tag: json:"barcode"
string
barcode
=
3
;
// @inject_tag: json:"goods_id"
string
goods_id
=
4
;
// @inject_tag: json:"goods_type
int64
goods_type
=
5
;
// @inject_tag: json:"supplier_id"
int64
supplier_id
=
6
;
// @inject_tag: json:"brand_id"
int64
brand_id
=
7
;
// @inject_tag: json:"class_id1"
int64
class_id1
=
8
;
// @inject_tag: json:"class_id2"
int64
class_id2
=
9
;
// @inject_tag: json:"goods_name"
string
goods_name
=
10
;
// @inject_tag: json:"status"
int64
status
=
11
;
// @inject_tag: json:"encoded"
string
encoded
=
12
;
// @inject_tag: json:"encap"
string
encap
=
13
;
// @inject_tag: json:"packing"
int64
packing
=
14
;
// @inject_tag: json:"goods_unit"
int64
goods_unit
=
15
;
// @inject_tag: json:"goods_images"
bool
goods_images
=
16
;
// @inject_tag: json:"pdf"
string
pdf
=
17
;
// @inject_tag: json:"goods_brief"
string
goods_brief
=
18
;
// @inject_tag: json:"moq"
int64
moq
=
19
;
// @inject_tag: json:"mpq"
int64
mpq
=
20
;
// @inject_tag: json:"ladder_price"
repeated
LadderPrice
ladder_price
=
21
;
// @inject_tag: json:"update_time"
int64
update_time
=
22
;
// @inject_tag: json:"sku_name"
string
sku_name
=
23
;
// @inject_tag: json:"mpl"
int64
mpl
=
24
;
// @inject_tag: json:"stock"
int64
stock
=
25
;
// @inject_tag: json:"attrs"
string
attrs
=
26
;
// @inject_tag: json:"cost"
string
cost
=
27
;
// @inject_tag: json:"new_cost"
string
new_cost
=
28
;
// @inject_tag: json:"supplier_stock"
int64
supplier_stock
=
29
;
// @inject_tag: json:"self_supplier_type"
int64
self_supplier_type
=
30
;
// @inject_tag: json:"cn_delivery_time"
string
cn_delivery_time
=
31
;
// @inject_tag: json:"brand_name"
string
brand_name
=
32
;
// @inject_tag: json:"supplier_name"
string
supplier_name
=
33
;
string
goods_unit_name
=
34
;
string
packing_name
=
35
;
string
mpq_unit_name
=
36
;
// @inject_tag: json:"ac_type"
int64
ac_type
=
37
;
int64
allow_coupon
=
38
;
string
class_id1_name
=
39
;
string
class_id2_name
=
40
;
// @inject_tag: json:"otheis_buyr_attrs"
int64
is_buy
=
41
;
// @inject_tag: json:"hk_delivery_type"
string
hk_delivery_type
=
42
;
}
\ No newline at end of file
service/attr_service.go
View file @
47163d07
...
...
@@ -18,6 +18,23 @@ import (
func
SearchAttr
(
attrOrigin
,
encap
string
)
(
goodsName
string
,
err
error
)
{
//先去切割参数得到参数列表
attrs
:=
splitAttrs
(
attrOrigin
)
//当切割出来的参数大于1个的时候,就要去针对每个参数进行里面再一次提纯
if
len
(
attrs
)
>
1
{
for
key
,
attr
:=
range
attrs
{
attrs
[
key
]
=
changeKeyword
(
attr
)
//切割完以后,还要去对切割后的参数提取值,因为有可能参数没有分隔符
extractRes
:=
extractAttr
(
attrs
[
key
])
for
ek
,
eAttr
:=
range
extractRes
{
if
ek
==
0
{
attrs
[
key
]
=
extractRes
[
0
]
}
else
{
attrs
=
append
(
attrs
,
eAttr
)
}
}
}
}
else
{
attrs
=
extractAttrsByStr
(
attrs
[
0
])
}
var
attrsSlice
[]
string
//去转换每一个参数,得到去查询es的标准格式
for
_
,
attr
:=
range
attrs
{
...
...
@@ -44,6 +61,10 @@ func SearchAttr(attrOrigin, encap string) (goodsName string, err error) {
index
:=
config
.
Get
(
"es.attr_index"
)
.
String
()
result
,
err
:=
es
.
CurlES
(
index
,
body
)
goodsName
=
gjson
.
Get
(
result
,
"hits.hits.0._source.goods_name"
)
.
String
()
//匹配参数不成功,要变回原来的值
if
goodsName
==
""
{
goodsName
=
attrOrigin
}
return
}
...
...
@@ -72,6 +93,33 @@ func splitAttrs(attrs string) (result []string) {
return
}
//提取参数
func
extractAttr
(
attr
string
)
[]
string
{
regexpUnit
:=
strings
.
Join
(
getNeedCheckUnit
(),
"|"
)
r
,
_
:=
regexp
.
Compile
(
"(
\\
d+[
\\
/
\\
d. ]*|
\\
d)("
+
regexpUnit
+
")"
+
""
)
res
:=
r
.
FindAllString
(
attr
,
100
)
return
res
}
//提取参数,从一个字符串里面,注意要提取出两个参数才当作是
func
extractAttrsByStr
(
attr
string
)
[]
string
{
regexpUnit
:=
strings
.
Join
(
getNeedCheckUnit
(),
"|"
)
r
,
_
:=
regexp
.
Compile
(
"(
\\
d+[
\\
/
\\
d. ]*|
\\
d)("
+
regexpUnit
+
")"
+
""
)
res
:=
r
.
FindAllString
(
attr
,
100
)
if
len
(
res
)
<
2
{
return
[]
string
{
attr
}
}
return
res
}
func
getNeedCheckUnit
()
(
unitSlice
[]
string
)
{
unitMapping
:=
common
.
UnitValueMapping
for
unit
,
_
:=
range
unitMapping
{
unitSlice
=
append
(
unitSlice
,
unit
)
}
return
}
//将写法转成正规写法,转换单位,比如有的人喜欢将Ω输成欧姆或者O,所以要统一转成正常的Ω
func
changeKeyword
(
attr
string
)
(
result
string
)
{
regulars
:=
common
.
KeywordRegular
...
...
service/bom_service.go
View file @
47163d07
...
...
@@ -25,7 +25,7 @@ func (bs *BomServiceImpl) AutoSpu(ctx context.Context, req *bom.AutoSpuRequest,
}
func
(
bs
*
BomServiceImpl
)
Recommend
(
ctx
context
.
Context
,
req
*
bom
.
RecommendRequest
,
rsp
*
bom
.
RecommendResponse
)
error
{
if
req
.
GoodsName
==
""
||
req
.
Flag
==
0
{
if
req
.
Flag
==
0
{
rsp
.
ErrorCode
=
101
rsp
.
ErrorMessage
=
"参数不全"
return
nil
...
...
@@ -66,7 +66,9 @@ func AutoSpu(goodsName string) []string {
func
getTermQuery
(
goodsName
string
)
(
query
*
elastic
.
BoolQuery
)
{
query
=
elastic
.
NewBoolQuery
()
query
.
Filter
(
elastic
.
NewTermQuery
(
"auto_goods_name"
,
goodsName
))
query
.
Filter
(
elastic
.
NewTermQuery
(
"status"
,
1
))
if
config
.
Get
(
"web.mode"
)
.
String
()
!=
"debug"
{
query
.
Filter
(
elastic
.
NewTermQuery
(
"status"
,
1
))
}
query
.
MustNot
(
elastic
.
NewTermQuery
(
"brand_id"
,
0
))
return
query
}
...
...
@@ -91,7 +93,7 @@ func Recommend(req *bom.RecommendRequest) (rsp *bom.ResponseData) {
//获取需要请求的索引
index
:=
getRecommendSearchIndex
(
req
)
//获取es的请求参数
queryJson
:=
getRecommendSearchParams
(
tru
e
,
req
)
queryJson
:=
getRecommendSearchParams
(
fals
e
,
req
)
result
,
err
:=
es
.
CurlES
(
index
,
queryJson
)
if
err
!=
nil
{
log
.
Error
(
err
)
...
...
@@ -170,7 +172,9 @@ func getBomTermQuery(goodsName, brandName string, number int32, isRawSearch bool
field
:=
"auto_goods_name"
query
=
query
.
Must
(
elastic
.
NewTermQuery
(
field
,
goodsName
))
}
//query = query.Filter(elastic.NewTermQuery("status", 1))
if
config
.
Get
(
"web.mode"
)
.
String
()
!=
"debug"
{
query
.
Filter
(
elastic
.
NewTermQuery
(
"status"
,
1
))
}
source
:=
elastic
.
NewSearchSource
()
.
Query
(
query
)
source
.
From
(
0
)
if
isRawSearch
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment