|
@@ -31,7 +31,7 @@ import (
|
|
|
const (
|
|
|
pageSize = 100
|
|
|
AllSubPushCacheSize = 200
|
|
|
- query = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area","city", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site","buyertel","buyerperson","agency","agencyperson","agencytel","winnerperson","winnertel","signendtime","bidendtime","entidlist","isValidFile", "detail"],"from":0,"size":%d}`
|
|
|
+ query = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area","city", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget","projectname","buyer","bidopentime","s_winner","filetext","spidercode","site","buyertel","buyerperson","agency","agencyperson","agencytel","winnerperson","winnertel","signendtime","bidendtime","entidlist","isValidFile"],"from":0,"size":%d}`
|
|
|
mongodb_fields = `{"_id":1,"area":1,"publishtime":1,"s_subscopeclass":1,"subtype":1,"title":1,"toptype":1,"type":1, "city":1,"buyerclass":1,"budget":1,"bidamount":1,"s_winner":1,"bidopentime":1,"buyer":1,"projectname":1,"filetext":1,"spidercode":1,"site":1,"buyertel":1,"buyerperson":1,"agency":1,"agencyperson":1,"agencytel":1,"winnerperson":1,"winnertel":1,"signendtime":1,"bidendtime":1,"entidlist":1,"isValidFile":1}`
|
|
|
|
|
|
SubFreeFlag = "fType"
|
|
@@ -1221,7 +1221,8 @@ func GetKeySet(t string, u *map[string]interface{}, data []string) (bool, []stri
|
|
|
const (
|
|
|
INDEX = "bidding"
|
|
|
TYPE = "bidding"
|
|
|
- bidField = `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","buyerclass","budget","bidamount","filetext","spidercode","site","buyer","bidopentime","buyertel","buyerperson","agency","agencyperson","agencytel","s_winner","winnerperson","winnertel","signendtime","bidendtime","entidlist", "detail"`
|
|
|
+ bidField = `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","buyerclass","budget","bidamount","filetext","spidercode","site","buyer","bidopentime","buyertel","buyerperson","agency","agencyperson","agencytel","s_winner","winnerperson","winnertel","signendtime","bidendtime","entidlist"`
|
|
|
+ bidField1 = `"_id","title","publishtime","toptype","subtype","type","area","city","s_subscopeclass","buyerclass","budget","bidamount","filetext","spidercode","site","buyer","bidopentime","buyertel","buyerperson","agency","agencyperson","agencytel","s_winner","winnerperson","winnertel","signendtime","bidendtime","entidlist","detail"`
|
|
|
bidTime = `{"range":{"publishtime":{"gt":%d}}}`
|
|
|
bidSort = `{"publishtime":"desc"}`
|
|
|
findfields = `"title"`
|
|
@@ -1239,7 +1240,8 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
|
|
|
logx.Info("--bsp:", bsp)
|
|
|
//获取查询语句
|
|
|
qstr := s.getDefaultDatasSQL(bsp)
|
|
|
- list := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, bidField, 0, bsp.Size, 500, false)
|
|
|
+ // 查询方式包含有正文,返回结果添加正文
|
|
|
+ list := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, common.ObjToString(common.If(strings.Contains(strings.Join(bsp.SelectType, ","), "detail"), bidField1, bidField)), 0, bsp.Size, 500, false)
|
|
|
logx.Info(time.Since(t1), "list count:", len(*list))
|
|
|
if list != nil && len(*list) > 0 {
|
|
|
var mlist []map[string]interface{}
|
|
@@ -2345,3 +2347,74 @@ func (s *SubPushQueryParam) ExportPushFormat() (ids, keyWords []string) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// @Author jianghan
|
|
|
+// @Description clickhouse获取推荐的列表数据
|
|
|
+// @Date 2024/3/11
|
|
|
+func (s *subscribePush) SubRecList(userId string, keyword []ViewKeyWord) (hasNextPage bool, total int64, resultList []*bxsubscribe.SubscribeInfo) {
|
|
|
+ sql := "select bitmapToArray(infoids) infoids, userid from jianyu.sub_recommend_list where userid = ?"
|
|
|
+ infos := IC.CkJy.SelectBySql(sql, userId)
|
|
|
+ if infos != nil && len(*infos) > 0 {
|
|
|
+ if ids, ok := (*infos)[0]["infoids"].([]uint64); ok && len(ids) > 0 {
|
|
|
+ length := len(ids)
|
|
|
+ resultList = make([]*bxsubscribe.SubscribeInfo, length)
|
|
|
+ esq := `{"query": {"bool": {"must": [{"terms": {"autoid": [` + strings.Join(gconv.Strings(ids), ",") + ` ]}}]}}}`
|
|
|
+ binfo := elastic.GetAllByNgram(INDEX, TYPE, esq, findfields, bidSort, bidField, 0, 100, length, false)
|
|
|
+ if binfo != nil && len(*binfo) > 0 {
|
|
|
+ for i, m := range *binfo {
|
|
|
+ title := strings.Replace(common.ObjToString(m["title"]), " ", "", -1)
|
|
|
+ matchkeys := getKeys(title, keyword)
|
|
|
+ resultList[i] = s.InfoFormat(&PushCa{
|
|
|
+ InfoId: mongodb.BsonIdToSId(m["_id"]),
|
|
|
+ Date: time.Now().Unix(),
|
|
|
+ Keys: matchkeys,
|
|
|
+ FileExists: m["filetext"] != nil,
|
|
|
+ }, &m, false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ total = int64(len(resultList))
|
|
|
+ if total > pageSize {
|
|
|
+ resultList = resultList[:pageSize]
|
|
|
+ hasNextPage = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// @Author jianghan
|
|
|
+// @Description es获取最新10条数据
|
|
|
+// @Date 2024/3/13
|
|
|
+func (s *subscribePush) GetRecListByEs() (hasNextPage bool, total int64, resultList []*bxsubscribe.SubscribeInfo) {
|
|
|
+ resultList = make([]*bxsubscribe.SubscribeInfo, 10)
|
|
|
+ if jsonStr := redis.GetStr("pushcache_2_c", "bid_sub_recommend"); jsonStr != "" {
|
|
|
+ var data []map[string]interface{}
|
|
|
+ _ = json.Unmarshal([]byte(jsonStr), &data)
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
+ resultList[i] = s.InfoFormat(&PushCa{
|
|
|
+ InfoId: common.ObjToString(data[i]["_id"]),
|
|
|
+ Date: time.Now().Unix(),
|
|
|
+ Keys: []string{},
|
|
|
+ FileExists: data[i]["filetext"] != nil,
|
|
|
+ }, &data[i], false)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ qstr := `{"query": {"bool": {"must": [{"match_all": {}}]}}}`
|
|
|
+ list := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, bidField, 0, 10, 10, false)
|
|
|
+ redis.Put("pushcache_2_c", "bid_sub_recommend", 1, 86400)
|
|
|
+ for i := 0; i < len(*list); i++ {
|
|
|
+ resultList[i] = s.InfoFormat(&PushCa{
|
|
|
+ InfoId: common.ObjToString((*list)[i]["_id"]),
|
|
|
+ Date: time.Now().Unix(),
|
|
|
+ Keys: []string{},
|
|
|
+ FileExists: (*list)[i]["filetext"] != nil,
|
|
|
+ }, &(*list)[i], false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ total = int64(len(resultList))
|
|
|
+ if total > pageSize {
|
|
|
+ resultList = resultList[:pageSize]
|
|
|
+ hasNextPage = true
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|