|
@@ -2,6 +2,7 @@ package bidSearch
|
|
|
|
|
|
import (
|
|
|
"aiChat/api/aiSearch/v1"
|
|
|
+ "aiChat/utility"
|
|
|
"context"
|
|
|
"fmt"
|
|
|
"strconv"
|
|
@@ -10,6 +11,7 @@ import (
|
|
|
|
|
|
. "app.yhyue.com/moapp/jybase/common"
|
|
|
elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
+ "app.yhyue.com/moapp/jybase/mapping"
|
|
|
"github.com/gogf/gf/v2/encoding/gjson"
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
@@ -22,7 +24,6 @@ const (
|
|
|
QueryBoolShould = `{"bool":{"should":[%s],"minimum_should_match": 1}}`
|
|
|
queryBoolMustBoolShould = `{"bool":{"must":[{"range":{"bidamount":{%s}}}]}},{"bool":{"must":[{"range":{"budget":{%s}}}],"must_not":[{"range":{"bidamount":{"gte":-1}}}]}}`
|
|
|
QueryBoolMustTermBool = `{"bool": {"must": [{ "term": {"%s": %t }}]}}`
|
|
|
- QueryBoolMustA = `{"bool":{"must":[{"terms":{"%s":[%s]}}]}}`
|
|
|
queryExists = `{"constant_score":{"filter":{"exists":{"field":"%s"}}}}`
|
|
|
gte = `"gte": %s`
|
|
|
lte = `"lte": %s`
|
|
@@ -30,6 +31,8 @@ const (
|
|
|
TYPE = "bidding"
|
|
|
BidSearchSort = `{"dataweight":"desc","publishtime":"desc"}`
|
|
|
BidSearchFieldBase = `"_id","title","publishtime","dataweight","toptype","subtype","type","area","city","s_subscopeclass","bidamount","budget","buyerclass","isValidFile","district"` //搜索列表基础字段
|
|
|
+ QueryTerms = `{"terms":{"%s":["%s"]}}`
|
|
|
+ QueryTermsDh = `","`
|
|
|
)
|
|
|
|
|
|
var (
|
|
@@ -45,30 +48,30 @@ var (
|
|
|
)
|
|
|
|
|
|
type BidSearch struct {
|
|
|
- ctx context.Context
|
|
|
+ Ctx context.Context
|
|
|
PositionId int64
|
|
|
- PageNum int64 //当前页码
|
|
|
- PageSize int64 //每页数量
|
|
|
- Province string //省份
|
|
|
- City string //城市
|
|
|
- Subtype string //信息类型-二级
|
|
|
- TopType string //信息类型-一级分类
|
|
|
- PublishTime string //发布时间
|
|
|
- SelectType string //搜索范围:标题;正文等
|
|
|
- Price string //价格
|
|
|
- Industry string //行业
|
|
|
- BuyerClass string //采购单位类型
|
|
|
- BuyerTel string //采购单位联系方式
|
|
|
- WinnerTel string //中标单位联系方式
|
|
|
- FileExists string //是否有附件
|
|
|
- WordsMode int64 //搜索关键词模式;默认0:包含所有,1:包含任意
|
|
|
- KeyWords string //关键词:多个空格隔开(主)
|
|
|
- AdditionalWords string //关键词:附加关键词(副:五组,每组最多15个字符)
|
|
|
- ExclusionWords string //关键词:排除词(副:五组,每组最多15个字符)
|
|
|
- District string //区县
|
|
|
- Buyer string //采购单位
|
|
|
- Winner string //中标企业
|
|
|
- Agency string //代理机构
|
|
|
+ PageNum int64 //当前页码
|
|
|
+ PageSize int64 //每页数量
|
|
|
+ Province []string //省份
|
|
|
+ City []string //城市
|
|
|
+ Subtype []string //信息类型-二级
|
|
|
+ TopType []string //信息类型-一级分类
|
|
|
+ PublishTime string //发布时间
|
|
|
+ SelectType string //搜索范围:标题;正文等
|
|
|
+ Price string //价格
|
|
|
+ Industry []string //行业
|
|
|
+ BuyerClass []string //采购单位类型
|
|
|
+ BuyerTel string //采购单位联系方式 是或否
|
|
|
+ WinnerTel string //中标单位联系方式 是或否
|
|
|
+ FileExists string //是否有附件
|
|
|
+ WordsMode int64 //搜索关键词模式;默认0:包含所有,1:包含任意
|
|
|
+ KeyWords string //关键词:多个空格隔开(主)
|
|
|
+ AdditionalWords string //关键词:附加关键词(副:五组,每组最多15个字符)
|
|
|
+ ExclusionWords string //关键词:排除词(副:五组,每组最多15个字符)
|
|
|
+ District []string //区县
|
|
|
+ Buyer string //采购单位
|
|
|
+ Winner string //中标企业
|
|
|
+ Agency string //代理机构
|
|
|
}
|
|
|
|
|
|
func NewBidSearch(ctx context.Context, positionId int64, content string) (*BidSearch, error) {
|
|
@@ -77,24 +80,67 @@ func NewBidSearch(ctx context.Context, positionId int64, content string) (*BidSe
|
|
|
g.Log().Error(ctx, positionId, "查询条件转换出错", e)
|
|
|
return nil, e
|
|
|
}
|
|
|
+ var paramFilter = func(v string) string {
|
|
|
+ if v == "全部" || v == "不限" {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ return strings.ReplaceAll(v, " ", "")
|
|
|
+ }
|
|
|
+ //
|
|
|
keyWords, exclusionWords := []string{}, []string{}
|
|
|
if keyWordJson := c.GetJson("关键词"); keyWordJson != nil {
|
|
|
keyWords = keyWordJson.Get("选择").Strings()
|
|
|
exclusionWords = keyWordJson.Get("排除").Strings()
|
|
|
}
|
|
|
- area, city := []string{}, []string{}
|
|
|
+ //
|
|
|
+ area, city, district := []string{}, []string{}, []string{}
|
|
|
if areaJson := c.GetJson("地区"); areaJson != nil {
|
|
|
- area = areaJson.Get("选择").Strings()
|
|
|
+ for _, v := range areaJson.Get("选择").Strings() {
|
|
|
+ vvs := strings.Split(v, " ")
|
|
|
+ for kk, vv := range vvs {
|
|
|
+ vv = paramFilter(vv)
|
|
|
+ if vv == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ vvv := strings.TrimSuffix(vv, "省")
|
|
|
+ _, ok := mapping.BidCodeMapping.Area[vvv]
|
|
|
+ if ok {
|
|
|
+ area = append(area, vvv)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ _, ok = mapping.BidCodeMapping.City[vv]
|
|
|
+ if ok {
|
|
|
+ city = append(city, vv)
|
|
|
+ }
|
|
|
+ if kk < 0 && mapping.BidCodeMapping.District[vvs[kk-1]] != nil {
|
|
|
+ _, ok = mapping.BidCodeMapping.District[vvs[kk-1]][vv]
|
|
|
+ if ok {
|
|
|
+ district = append(district, vv)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !ok {
|
|
|
+ _, ok = utility.AllDistrict[vv]
|
|
|
+ if ok {
|
|
|
+ district = append(district, vv)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//exclusionArea = areaJson.Get("排除").Strings()
|
|
|
}
|
|
|
subtype, topType := []string{}, []string{}
|
|
|
- publishTime := "lately-30"
|
|
|
- var paramFilter = func(v string) string {
|
|
|
- if v == "全部" || v == "不限" {
|
|
|
- return ""
|
|
|
+ for _, v := range c.Get("信息类型").Strings() {
|
|
|
+ v = paramFilter(v)
|
|
|
+ if vv, ok := topTypeMap[v]; ok {
|
|
|
+ topType = append(topType, vv)
|
|
|
+ } else if _, ok := mapping.BidCodeMapping.Toptype[v]; ok {
|
|
|
+ topType = append(topType, v)
|
|
|
+ } else if _, ok := mapping.BidCodeMapping.Subtype[v]; ok {
|
|
|
+ subtype = append(subtype, v)
|
|
|
}
|
|
|
- return strings.ReplaceAll(v, " ", "")
|
|
|
}
|
|
|
+ publishTime := "lately-30"
|
|
|
+ //
|
|
|
pt := paramFilter(c.Get("发布时间范围").String())
|
|
|
if pts := strings.Split(pt, "-"); len(pts) == 2 {
|
|
|
pt_s, pt_s_e := gtime.StrToTimeFormat(pts[0], "Ymd")
|
|
@@ -105,26 +151,31 @@ func NewBidSearch(ctx context.Context, positionId int64, content string) (*BidSe
|
|
|
publishTime = fmt.Sprintf("%d-%d", pt_s.Unix(), pt_e.Unix())
|
|
|
}
|
|
|
}
|
|
|
- price := strings.ReplaceAll(paramFilter(c.Get("金额").String()), "万", "")
|
|
|
- industry := paramFilter(c.Get("industry").String())
|
|
|
- buyerClass := paramFilter(c.Get("采购单位类型").String())
|
|
|
- buyerTel := paramFilter(c.Get("采购单位联系方式").String())
|
|
|
- winnerTel := paramFilter(c.Get("中标单位联系方式").String())
|
|
|
+ //
|
|
|
+ price := paramFilter(c.Get("金额").String())
|
|
|
+ price = strings.ReplaceAll(price, "以上", "-")
|
|
|
+ price = strings.ReplaceAll(price, "万", "")
|
|
|
+ //
|
|
|
selectType := []string{}
|
|
|
- for _, t := range strings.Split(paramFilter(c.Get("搜索范围").String()), ",") {
|
|
|
- if t == "content" {
|
|
|
+ for _, t := range c.Get("搜索范围").Strings() {
|
|
|
+ t = paramFilter(t)
|
|
|
+ if t == "正文" {
|
|
|
selectType = append(selectType, "detail")
|
|
|
} else if t == "buyer" {
|
|
|
selectType = append(selectType, "buyer.mbuyer")
|
|
|
- } else if t == "winner" {
|
|
|
+ } else if t == "中标企业" {
|
|
|
selectType = append(selectType, "s_winner.mwinner")
|
|
|
} else if t == "agency" {
|
|
|
selectType = append(selectType, "agency.magency")
|
|
|
- } else if t == "title" {
|
|
|
+ } else if t == "标题" {
|
|
|
selectType = append(selectType, "title")
|
|
|
- } else if t == "ppa" {
|
|
|
- selectType = append(selectType, []string{"purchasing", "projectnamb.pname"}...)
|
|
|
- } else if t == "file" { //dev4.7.8 标讯优化:搜索范围附件-》全部用户可用
|
|
|
+ } else if t == "项目名称/标的物" {
|
|
|
+ selectType = append(selectType, "purchasing", "projectnamb.pname")
|
|
|
+ } else if t == "项目名称" {
|
|
|
+ selectType = append(selectType, "projectnamb.pname")
|
|
|
+ } else if t == "标的物" {
|
|
|
+ selectType = append(selectType, "purchasing")
|
|
|
+ } else if t == "附件" { //dev4.7.8 标讯优化:搜索范围附件-》全部用户可用
|
|
|
selectType = append(selectType, "filetext")
|
|
|
}
|
|
|
}
|
|
@@ -136,26 +187,27 @@ func NewBidSearch(ctx context.Context, positionId int64, content string) (*BidSe
|
|
|
wordsMode = 1
|
|
|
}
|
|
|
bs := &BidSearch{
|
|
|
+ Ctx: ctx,
|
|
|
PositionId: positionId,
|
|
|
PageNum: 0, //当前页码
|
|
|
PageSize: g.Cfg("ai_search.yaml").MustGet(ctx, "allBidListMaxLen").Int64(), //每页数量
|
|
|
- Province: strings.Join(area, ","), //省份
|
|
|
- City: strings.Join(city, ","), //城市
|
|
|
- Subtype: strings.Join(subtype, ","), //信息类型-二级
|
|
|
- TopType: strings.Join(topType, ","), //信息类型-一级分类
|
|
|
+ Province: area, //省份
|
|
|
+ City: city, //城市
|
|
|
+ Subtype: subtype, //信息类型-二级
|
|
|
+ TopType: topType, //信息类型-一级分类
|
|
|
PublishTime: publishTime, //发布时间
|
|
|
SelectType: strings.Join(selectType, ","), //搜索范围:标题;正文等
|
|
|
Price: price, //价格
|
|
|
- Industry: industry, //行业
|
|
|
- BuyerClass: buyerClass, //采购单位类型
|
|
|
- BuyerTel: buyerTel, //采购单位联系方式
|
|
|
- WinnerTel: winnerTel, //中标单位联系方式
|
|
|
+ Industry: nil, //行业
|
|
|
+ BuyerClass: nil, //采购单位类型
|
|
|
+ BuyerTel: paramFilter(c.Get("采购单位联系方式").String()), //采购单位联系方式
|
|
|
+ WinnerTel: paramFilter(c.Get("中标单位联系方式").String()), //中标单位联系方式
|
|
|
FileExists: "", //是否有附件
|
|
|
WordsMode: wordsMode, //搜索关键词模式;默认0:包含所有,1:包含任意
|
|
|
KeyWords: strings.Join(keyWords, " "), //关键词:多个空格隔开(主)
|
|
|
AdditionalWords: "", //关键词:附加关键词(副:五组,每组最多15个字符)
|
|
|
ExclusionWords: strings.Join(exclusionWords, ","), //关键词:排除词(副:五组,每组最多15个字符)
|
|
|
- District: "",
|
|
|
+ District: district,
|
|
|
Buyer: paramFilter(c.Get("采购单位").String()),
|
|
|
Winner: paramFilter(c.Get("中标企业").String()),
|
|
|
Agency: paramFilter(c.Get("招标代理").String()),
|
|
@@ -199,14 +251,14 @@ func (b *BidSearch) Search() (string, []*v1.ResBidding) {
|
|
|
|
|
|
// GetSearchQuery 整理关键词等查询条件
|
|
|
func (b *BidSearch) GetSearchQuery() (qstr string) {
|
|
|
- mustQuery := b.MustQuery()
|
|
|
+ musts := b.MustQuery()
|
|
|
var (
|
|
|
//搜索范围是否只有附件
|
|
|
//搜索范围只选择附件,是否有附件条件无效;
|
|
|
- isFileSearch = b.SelectType == "filetext"
|
|
|
- wordsMusts, wordsShould, musts, mustNot []string
|
|
|
- findFields string
|
|
|
- selectTypeArr = strings.Split(b.SelectType, ",")
|
|
|
+ isFileSearch = b.SelectType == "filetext"
|
|
|
+ wordsMusts, wordsShould, mustNot []string
|
|
|
+ findFields string
|
|
|
+ selectTypeArr = strings.Split(b.SelectType, ",")
|
|
|
)
|
|
|
if selectTypeArr == nil || len(selectTypeArr) == 0 {
|
|
|
findFields = `"title"`
|
|
@@ -214,9 +266,6 @@ func (b *BidSearch) GetSearchQuery() (qstr string) {
|
|
|
findFields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
|
|
|
}
|
|
|
switchBool := strings.Contains(findFields, "detail") && strings.Contains(findFields, "title")
|
|
|
- if mustQuery != "" {
|
|
|
- musts = append(musts, mustQuery)
|
|
|
- }
|
|
|
//采购单位
|
|
|
if b.Buyer != "" {
|
|
|
musts = append(musts, b.GetMatchArrSql("buyer.mbuyer", strings.Split(b.Buyer, ",")...))
|
|
@@ -330,8 +379,8 @@ func (b *BidSearch) GetSearchQuery() (qstr string) {
|
|
|
mustNot = append(mustNot, fmt.Sprintf(QueryBoolShould, strings.Join(notKeyMustNot, ",")))
|
|
|
}
|
|
|
//行业
|
|
|
- if b.Industry != "" {
|
|
|
- musts = append(musts, fmt.Sprintf(QueryBoolMustA, "s_subscopeclass", `"`+strings.ReplaceAll(b.Industry, ",", `","`)+`"`))
|
|
|
+ if len(b.Industry) > 0 {
|
|
|
+ musts = append(musts, fmt.Sprintf(QueryTerms, "s_subscopeclass", strings.Join(b.Industry, QueryTermsDh)))
|
|
|
}
|
|
|
//价格
|
|
|
if b.Price != "" && len(strings.Split(b.Price, "-")) > 1 {
|
|
@@ -368,84 +417,48 @@ func (b *BidSearch) GetSearchQuery() (qstr string) {
|
|
|
}
|
|
|
}
|
|
|
//采购单位联系方式
|
|
|
- hasBuyerTel := b.BuyerTel
|
|
|
- if hasBuyerTel != "" {
|
|
|
- if hasBuyerTel == "y" {
|
|
|
+ if b.BuyerTel != "" {
|
|
|
+ if b.BuyerTel == "是" {
|
|
|
musts = append(musts, fmt.Sprintf(queryExists, "buyertel"))
|
|
|
- } else {
|
|
|
+ } else if b.BuyerTel == "否" {
|
|
|
mustNot = append(mustNot, fmt.Sprintf(queryExists, "buyertel"))
|
|
|
}
|
|
|
}
|
|
|
//中标企业联系方式
|
|
|
- hasWinnerTel := b.WinnerTel
|
|
|
- if hasWinnerTel != "" {
|
|
|
- if hasWinnerTel == "y" {
|
|
|
+ if b.WinnerTel != "" {
|
|
|
+ if b.WinnerTel == "是" {
|
|
|
musts = append(musts, fmt.Sprintf(queryExists, "winnertel"))
|
|
|
- } else {
|
|
|
+ } else if b.WinnerTel == "否" {
|
|
|
mustNot = append(mustNot, fmt.Sprintf(queryExists, "winnertel"))
|
|
|
}
|
|
|
}
|
|
|
//附件--非BI
|
|
|
- fileExists := b.FileExists
|
|
|
- if !isFileSearch && fileExists != "" {
|
|
|
- if fileExists == "1" { //有附件
|
|
|
+ if !isFileSearch && b.FileExists != "" {
|
|
|
+ if b.FileExists == "是" { //有附件
|
|
|
musts = append(musts, fmt.Sprintf(QueryBoolMustTermBool, "isValidFile", true))
|
|
|
- } else if fileExists == "-1" { //无附件
|
|
|
+ } else if b.FileExists == "否" { //无附件
|
|
|
mustNot = append(mustNot, fmt.Sprintf(QueryBoolMustTermBool, "isValidFile", true))
|
|
|
}
|
|
|
}
|
|
|
//b.BidField 剑鱼默认招标信息搜索 此参数为空**
|
|
|
qstr = fmt.Sprintf(Query, strings.Join(musts, ","), strings.Join(mustNot, ","), fmt.Sprintf(`,"_source":[%s],"sort":[%s],"from":%d,"size":%d`, BidSearchFieldBase, BidSearchSort, b.PageNum, b.PageSize))
|
|
|
+ g.Log().Info(b.Ctx, b.PositionId, "es查询条件", qstr)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetBidSearchQuery 整理地区、城市、发布时间、信息类型、采购单位类型 查询条件
|
|
|
-func (b *BidSearch) MustQuery() string {
|
|
|
- query := ``
|
|
|
+func (b *BidSearch) MustQuery() []string {
|
|
|
+ querys := []string{}
|
|
|
//省份
|
|
|
- area := b.Province
|
|
|
- if area != "" {
|
|
|
- query += `{"terms":{"area":[`
|
|
|
- for k, v := range strings.Split(area, ",") {
|
|
|
- if k > 0 {
|
|
|
- query += `,`
|
|
|
- }
|
|
|
- query += `"` + v + `"`
|
|
|
- }
|
|
|
- query += `]}}`
|
|
|
+ if len(b.Province) > 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf(QueryTerms, "area", strings.Join(b.Province, QueryTermsDh)))
|
|
|
}
|
|
|
//市--未登录用户不能根据市和地区筛选
|
|
|
- city := b.City
|
|
|
- if city != "" {
|
|
|
- if len(query) > 0 {
|
|
|
- query += ","
|
|
|
- }
|
|
|
- query += `{"terms":{"city":[`
|
|
|
- for k, v := range strings.Split(city, ",") {
|
|
|
- if k > 0 {
|
|
|
- query += `,`
|
|
|
- }
|
|
|
- query += `"` + v + `"`
|
|
|
- }
|
|
|
- query += `]}}`
|
|
|
- }
|
|
|
- district := b.District
|
|
|
- if district != "" {
|
|
|
- if len(query) > 0 {
|
|
|
- query += ","
|
|
|
- }
|
|
|
- for k, v := range strings.Split(district, ",") {
|
|
|
- if k > 0 {
|
|
|
- query += `,`
|
|
|
- }
|
|
|
- cityName := strings.Split(v, "_")[0]
|
|
|
- districtName := strings.Split(v, "_")[1]
|
|
|
- queryBoolMustAndDistrict := `{"bool":{"must":[{"terms":{"city":["%s"]}},{"terms":{"district":["%s"]}}]}}`
|
|
|
- query += fmt.Sprintf(queryBoolMustAndDistrict, cityName, districtName)
|
|
|
- }
|
|
|
+ if len(b.City) > 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf(QueryTerms, "city", strings.Join(b.City, QueryTermsDh)))
|
|
|
}
|
|
|
- if query != "" {
|
|
|
- query = fmt.Sprintf(QueryBoolShould, query)
|
|
|
+ if len(b.District) > 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf(QueryTerms, "district", strings.Join(b.District, QueryTermsDh)))
|
|
|
}
|
|
|
//发布时间
|
|
|
publishTime := b.PublishTime
|
|
@@ -479,10 +492,7 @@ func (b *BidSearch) MustQuery() string {
|
|
|
}
|
|
|
}
|
|
|
if startTime != "" || endTime != "" {
|
|
|
- if len(query) > 0 {
|
|
|
- query += ","
|
|
|
- }
|
|
|
- query += `{"range":{"publishtime":{`
|
|
|
+ query := `{"range":{"publishtime":{`
|
|
|
if startTime != "" {
|
|
|
query += `"gte":` + startTime
|
|
|
}
|
|
@@ -493,69 +503,22 @@ func (b *BidSearch) MustQuery() string {
|
|
|
query += `"lt":` + endTime
|
|
|
}
|
|
|
query += `}}}`
|
|
|
+ querys = append(querys, query)
|
|
|
}
|
|
|
}
|
|
|
- //信息类型-二级
|
|
|
- subtype := b.Subtype
|
|
|
- topType := If(b.TopType != "", strings.Split(b.TopType, ","), []string{}).([]string)
|
|
|
- allType := ``
|
|
|
- //二级分类
|
|
|
- if subtype != "" {
|
|
|
- var typeInt = 0
|
|
|
- allType += `{"terms":{"subtype":[`
|
|
|
- for k, v := range strings.Split(subtype, ",") {
|
|
|
- if tType := If(topTypeMap[v] != "" && b.TopType == "", topTypeMap[v], "").(string); tType != "" {
|
|
|
- topType = append(topType, tType)
|
|
|
- typeInt += 1
|
|
|
- continue
|
|
|
- }
|
|
|
- if k > typeInt {
|
|
|
- allType += `,`
|
|
|
- }
|
|
|
- allType += `"` + v + `"`
|
|
|
- }
|
|
|
- allType += `]}}`
|
|
|
- if typeInt == len(strings.Split(subtype, ",")) {
|
|
|
- allType = ``
|
|
|
- }
|
|
|
+ //信息类型 二级分类
|
|
|
+ if len(b.Subtype) > 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf(QueryTerms, "subtype", strings.Join(b.Subtype, QueryTermsDh)))
|
|
|
}
|
|
|
//信息类型 一级分类
|
|
|
- if len(topType) > 0 {
|
|
|
- if allType != "" {
|
|
|
- allType += ","
|
|
|
- }
|
|
|
- allType += `{"terms":{"toptype":[`
|
|
|
- for k, v := range topType {
|
|
|
- if k > 0 {
|
|
|
- allType += `,`
|
|
|
- }
|
|
|
- allType += `"` + v + `"`
|
|
|
- }
|
|
|
- allType += `]}}`
|
|
|
- }
|
|
|
-
|
|
|
- if allType != "" {
|
|
|
- if query != "" {
|
|
|
- query += ","
|
|
|
- }
|
|
|
- query += fmt.Sprintf(QueryBoolShould, allType)
|
|
|
+ if len(b.TopType) > 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf(QueryTerms, "toptype", strings.Join(b.TopType, QueryTermsDh)))
|
|
|
}
|
|
|
//采购单位类型
|
|
|
- buyerClass := b.BuyerClass
|
|
|
- if buyerClass != "" {
|
|
|
- if len(query) > 0 {
|
|
|
- query += ","
|
|
|
- }
|
|
|
- query += `{"terms":{"buyerclass":[`
|
|
|
- for k, v := range strings.Split(buyerClass, ",") {
|
|
|
- if k > 0 {
|
|
|
- query += `,`
|
|
|
- }
|
|
|
- query += `"` + v + `"`
|
|
|
- }
|
|
|
- query += `]}`
|
|
|
+ if len(b.BuyerClass) > 0 {
|
|
|
+ querys = append(querys, fmt.Sprintf(QueryTerms, "buyerclass", strings.Join(b.BuyerClass, QueryTermsDh)))
|
|
|
}
|
|
|
- return query
|
|
|
+ return querys
|
|
|
}
|
|
|
|
|
|
// DetailFileORTitle 包含正文或 附件 不包含标题
|
|
@@ -592,7 +555,7 @@ func (b *BidSearch) GetMatchArrSql(field string, val ...string) (sql string) {
|
|
|
}
|
|
|
|
|
|
// IndustryFormat 行业处理
|
|
|
-func (b *BidSearch) IndustryFormat(industry, subScopeClass string) (newIndustry string) {
|
|
|
+func (b *BidSearch) IndustryFormat(industry []string, subScopeClass string) (newIndustry string) {
|
|
|
commonSubstring := func(v string) (value string) {
|
|
|
bcs := strings.Split(v, "_")
|
|
|
if len(bcs) == 1 {
|
|
@@ -610,13 +573,12 @@ func (b *BidSearch) IndustryFormat(industry, subScopeClass string) (newIndustry
|
|
|
return
|
|
|
}
|
|
|
//搜索条件中没有行业的话,取查询结果中第一个行业
|
|
|
- if industry == "" {
|
|
|
+ if len(industry) == 0 {
|
|
|
newIndustry = commonSubstring(bct[0])
|
|
|
} else { //搜索条件中有行业的话,取行业中和搜索条件相对应的第一个
|
|
|
- industryArr := strings.Split(industry, ",")
|
|
|
L:
|
|
|
for _, bc := range bct {
|
|
|
- for _, is := range industryArr {
|
|
|
+ for _, is := range industry {
|
|
|
if bc == is {
|
|
|
newIndustry = strings.TrimSpace(commonSubstring(bc))
|
|
|
break L
|