|
@@ -284,9 +284,11 @@ func (so *SearchOptimize) GetBidSearchList(isCache bool) (count, total int64, li
|
|
|
if start >= 0 {
|
|
|
t := time.Now()
|
|
|
fields := util.If(so.IsPay, BidSearchFieldOfVip, BidSearchFieldBase).(string)
|
|
|
+ esIndex := util.If(so.UserId == "", INDEXOther, INDEX).(string)
|
|
|
+ esType := util.If(so.UserId == "", TYPEOther, TYPE).(string)
|
|
|
biddingSearch := SearchByES{
|
|
|
- Index: INDEX,
|
|
|
- IType: TYPE,
|
|
|
+ Index: esIndex,
|
|
|
+ IType: esType,
|
|
|
Query: so.GetSearchQuery(so.GetBidSearchQuery()),
|
|
|
FindFields: util.If(isCache, "title", "detail").(string),
|
|
|
Order: BidSearchSort,
|
|
@@ -295,6 +297,7 @@ func (so *SearchOptimize) GetBidSearchList(isCache bool) (count, total int64, li
|
|
|
Limit: util.If(isCache, util.If(so.IsPay, bidsearch.SearchMaxPageCount_PAYED, bidsearch.SearchMaxPageCount_PC).(int), so.PageSize).(int), //缓存数据: 付费或未登录用户一次性5000条,100页数据;免费用户一次性500条,10页数据;实时数据:每页50条数据请求
|
|
|
Count: util.If(strings.Contains(so.SelectType, "detail"), 115, 0).(int), //高亮正文数量
|
|
|
HighLight: util.If(strings.Contains(so.SelectType, "detail"), true, false).(bool), //是否高亮正文
|
|
|
+ IsLogin: so.UserId != "",
|
|
|
}
|
|
|
var repl *[]map[string]interface{}
|
|
|
total, repl = biddingSearch.GetAllByNgramWithCount()
|
|
@@ -366,6 +369,7 @@ func (so *SearchOptimize) GetSearchQuery(mustQuery string) (qstr string) {
|
|
|
//搜索范围只选择附件,是否有附件条件无效;
|
|
|
isFileSearch = so.SelectType == "filetext"
|
|
|
selectTypeArr = strings.Split(so.SelectType, ",")
|
|
|
+ isLogin = so.UserId == ""
|
|
|
)
|
|
|
if mustQuery != "" {
|
|
|
musts = append(musts, mustQuery)
|
|
@@ -477,11 +481,11 @@ func (so *SearchOptimize) GetSearchQuery(mustQuery string) (qstr string) {
|
|
|
mustNot = append(mustNot, fmt.Sprintf(queryBoolShould, strings.Join(notKeyMustNot, ",")))
|
|
|
}
|
|
|
//行业
|
|
|
- if so.Industry != "" {
|
|
|
+ if so.Industry != "" && isLogin {
|
|
|
musts = append(musts, fmt.Sprintf(queryBoolMust, `"`+strings.ReplaceAll(so.Industry, ",", `","`)+`"`))
|
|
|
}
|
|
|
//价格
|
|
|
- if so.Price != "" && len(strings.Split(so.Price, "-")) > 1 {
|
|
|
+ if so.Price != "" && len(strings.Split(so.Price, "-")) > 1 && isLogin {
|
|
|
minPrice, maxPrice := strings.Split(so.Price, "-")[0], strings.Split(so.Price, "-")[1]
|
|
|
if minPrice != "" || maxPrice != "" {
|
|
|
sq := ``
|
|
@@ -515,7 +519,7 @@ func (so *SearchOptimize) GetSearchQuery(mustQuery string) (qstr string) {
|
|
|
}
|
|
|
//采购单位联系方式
|
|
|
hasBuyerTel := so.BuyerTel
|
|
|
- if hasBuyerTel != "" {
|
|
|
+ if hasBuyerTel != "" && isLogin {
|
|
|
if hasBuyerTel == "y" {
|
|
|
musts = append(musts, fmt.Sprintf(queryExists, "buyertel"))
|
|
|
} else {
|
|
@@ -524,7 +528,7 @@ func (so *SearchOptimize) GetSearchQuery(mustQuery string) (qstr string) {
|
|
|
}
|
|
|
//中标企业联系方式
|
|
|
hasWinnerTel := so.WinnerTel
|
|
|
- if hasWinnerTel != "" {
|
|
|
+ if hasWinnerTel != "" && isLogin {
|
|
|
if hasWinnerTel == "y" {
|
|
|
musts = append(musts, fmt.Sprintf(queryExists, "winnertel"))
|
|
|
} else {
|
|
@@ -533,7 +537,7 @@ func (so *SearchOptimize) GetSearchQuery(mustQuery string) (qstr string) {
|
|
|
}
|
|
|
//附件
|
|
|
fileExists := so.FileExists
|
|
|
- if !isFileSearch && fileExists != "" {
|
|
|
+ if !isFileSearch && fileExists != "" && isLogin {
|
|
|
if fileExists == "1" { //有附件
|
|
|
musts = append(musts, fmt.Sprintf(queryBoolMustTerm, true))
|
|
|
} else if fileExists == "-1" { //无附件
|
|
@@ -554,7 +558,8 @@ func (so *SearchOptimize) GetBidSearchQuery() string {
|
|
|
query := ``
|
|
|
//省份
|
|
|
area := so.Province
|
|
|
- if area != "" {
|
|
|
+ isLogin := so.UserId != ""
|
|
|
+ if area != "" && isLogin {
|
|
|
query += `{"terms":{"area":[`
|
|
|
for k, v := range strings.Split(area, ",") {
|
|
|
if k > 0 {
|
|
@@ -566,7 +571,7 @@ func (so *SearchOptimize) GetBidSearchQuery() string {
|
|
|
}
|
|
|
//
|
|
|
city := so.City
|
|
|
- if city != "" {
|
|
|
+ if city != "" && isLogin {
|
|
|
if len(query) > 0 {
|
|
|
query += ","
|
|
|
}
|
|
@@ -669,7 +674,7 @@ func (so *SearchOptimize) GetBidSearchQuery() string {
|
|
|
query += fmt.Sprintf(queryBoolShould, allType)
|
|
|
}
|
|
|
//采购单位类型
|
|
|
- if so.BuyerClass != "" {
|
|
|
+ if so.BuyerClass != "" && isLogin {
|
|
|
if len(query) > 0 {
|
|
|
query += ","
|
|
|
}
|
|
@@ -749,6 +754,7 @@ type SearchByES struct {
|
|
|
Limit int
|
|
|
Count int
|
|
|
HighLight bool
|
|
|
+ IsLogin bool
|
|
|
}
|
|
|
|
|
|
// GetAllByNgramWithCount 获取es查询结果及总数量
|
|
@@ -772,7 +778,11 @@ func (e *SearchByES) GetAllByNgramWithCount() (int64, *[]map[string]interface{})
|
|
|
queryStr = queryStr[:len(queryStr)-1] + `,"from":` + strconv.Itoa(e.Start) + `,"size":` + strconv.Itoa(e.Limit) + "}"
|
|
|
}
|
|
|
log.Println("queryStr:", queryStr)
|
|
|
- return elastic.GetWithCount(e.Index, e.IType, e.Query, queryStr)
|
|
|
+ if e.IsLogin {
|
|
|
+ return elastic.GetWithCount(e.Index, e.IType, e.Query, queryStr)
|
|
|
+ } else {
|
|
|
+ return pc.Other.GetWithCount(e.Index, e.IType, e.Query, queryStr)
|
|
|
+ }
|
|
|
} else {
|
|
|
return 0, nil
|
|
|
}
|