|
@@ -1075,11 +1075,19 @@ 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, 0, false)
|
|
|
- //logx.Info(time.Since(t1), "count:", len(*list))
|
|
|
+ list := elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSort, bidField, 0, bsp.Size, 500, false)
|
|
|
+ logx.Info(time.Since(t1), "list count:", len(*list))
|
|
|
if list != nil && len(*list) > 0 {
|
|
|
- total = int64(len(*list))
|
|
|
- result = s.listManager(spqp, *list, bsp.Keyword)
|
|
|
+ var mlist []map[string]interface{}
|
|
|
+ esM := listHistory(spqp)
|
|
|
+ for _, m := range *list {
|
|
|
+ if !esM[common.ObjToString(m["_id"])] {
|
|
|
+ mlist = append(mlist, m)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logx.Info(time.Since(t1), "mlist count:", len(mlist))
|
|
|
+ total = int64(len(mlist))
|
|
|
+ result = s.listManager(spqp, mlist, bsp.Keyword)
|
|
|
if len(result) > pageSize {
|
|
|
result = result[:pageSize]
|
|
|
hasNextPage = true
|
|
@@ -1090,6 +1098,17 @@ func (s *subscribePush) DefaultDatas(spqp *SubPushQueryParam, bsp *ViewCondition
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// 历史订阅消息
|
|
|
+func listHistory(spqp *SubPushQueryParam) map[string]bool {
|
|
|
+ m := make(map[string]bool)
|
|
|
+ sql := "SELECT infoid FROM push.pushentniche where userid = ? order by date desc, id desc limit 1000;"
|
|
|
+ info := spqp.BaseServiceMysql.SelectBySql(sql, spqp.NewUserId)
|
|
|
+ for _, m1 := range *info {
|
|
|
+ m[common.ObjToString(m1["infoid"])] = true
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
// 保存推送表
|
|
|
func (s *subscribePush) listManager(spqp *SubPushQueryParam, list []map[string]interface{}, keyword []ViewKeyWord) (resultList []*bxsubscribe.SubscribeInfo) {
|
|
|
now := time.Now().Unix()
|
|
@@ -1202,7 +1221,7 @@ func getKeys(title string, keywords []ViewKeyWord) (str []string) {
|
|
|
|
|
|
// 获取查询语句
|
|
|
func (s *subscribePush) getDefaultDatasSQL(bsp *ViewCondition) (str string) {
|
|
|
- query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}, "size": 500}`
|
|
|
+ query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}}`
|
|
|
query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
|
|
|
multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
|
|
|
query_bool_must_and := `{"bool":{"must":[%s]%s}}`
|