|
@@ -4,6 +4,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"jy/src/jfw/config"
|
|
|
+ "jy/src/jfw/jyutil"
|
|
|
"log"
|
|
|
"net/http"
|
|
|
"strconv"
|
|
@@ -297,7 +298,16 @@ 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 != "",
|
|
|
+ State: func(userId string, isPay bool) (state int) {
|
|
|
+ state = 1
|
|
|
+ if userId != "" {
|
|
|
+ state = 2
|
|
|
+ if isPay {
|
|
|
+ state = 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }(so.UserId, so.IsPay),
|
|
|
}
|
|
|
var repl *[]map[string]interface{}
|
|
|
total, repl = biddingSearch.GetAllByNgramWithCount()
|
|
@@ -764,11 +774,18 @@ type SearchByES struct {
|
|
|
Limit int
|
|
|
Count int
|
|
|
HighLight bool
|
|
|
- IsLogin bool
|
|
|
+ State int //1:noLogin;2:free;3:pay
|
|
|
}
|
|
|
|
|
|
// GetAllByNgramWithCount 获取es查询结果及总数量
|
|
|
func (e *SearchByES) GetAllByNgramWithCount() (int64, *[]map[string]interface{}) {
|
|
|
+ var (
|
|
|
+ jyES = jyutil.GetES(e.State)
|
|
|
+ )
|
|
|
+ if jyES.EsIndex != "" {
|
|
|
+ e.Index = jyES.EsIndex
|
|
|
+ e.IType = jyES.EsType
|
|
|
+ }
|
|
|
if e.Query != "" {
|
|
|
queryStr := e.Query
|
|
|
if e.HighLight {
|
|
@@ -787,12 +804,13 @@ func (e *SearchByES) GetAllByNgramWithCount() (int64, *[]map[string]interface{})
|
|
|
if e.Start > -1 {
|
|
|
queryStr = queryStr[:len(queryStr)-1] + `,"from":` + strconv.Itoa(e.Start) + `,"size":` + strconv.Itoa(e.Limit) + "}"
|
|
|
}
|
|
|
- log.Println("queryStr:", 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)
|
|
|
- }
|
|
|
+ log.Println(e.Index, e.IType, "--queryStr:", 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)
|
|
|
+ //}
|
|
|
+ return jyES.Es.GetWithCount(e.Index, e.IType, e.Query, queryStr)
|
|
|
} else {
|
|
|
return 0, nil
|
|
|
}
|