From 0559bfb0865ec743c5d643573b847232cffb6404 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Fri, 2 Aug 2024 16:48:15 +0800 Subject: [PATCH] feat: search messages to filter out notifications --- pkg/common/storage/database/mgo/msg.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/common/storage/database/mgo/msg.go b/pkg/common/storage/database/mgo/msg.go index 03f47c503..7dc308a7c 100644 --- a/pkg/common/storage/database/mgo/msg.go +++ b/pkg/common/storage/database/mgo/msg.go @@ -377,8 +377,19 @@ func (m *MsgMgo) searchMessageIndex(ctx context.Context, filter any, nextID prim if !nextID.IsZero() { pipeline = append(pipeline, bson.M{"$match": bson.M{"_id": bson.M{"$gt": nextID}}}) } + coarseFilter := bson.M{ + "$or": bson.A{ + bson.M{ + "doc_id": primitive.Regex{Pattern: "^sg_"}, + }, + bson.M{ + "doc_id": primitive.Regex{Pattern: "^si_"}, + }, + }, + } pipeline = append(pipeline, bson.M{"$sort": bson.M{"_id": 1}}, + bson.M{"$match": coarseFilter}, bson.M{"$match": filter}, bson.M{"$limit": limit}, bson.M{