Hello, I am trying to do a nested search on an joined collection using aggregation but from the documentation, I can use $text on the root collection, nothing on the nested collection. Is it possible to achieve this?
Here’s my code
matchStage := bson.D{{"$match", bson.D{{"user_id", userID}}}}
lookupStage := bson.D{{"$lookup", bson.D{
{"from", "members"},
{"localField", "member_id"},
{"foreignField", "_id"},
{"as", "members"}},
}}
cursor, cursorErr := r.connect.User.Aggregate(ctx, mongo.Pipeline{
matchStage, lookupStage,
})
regular search looks like this
matchStage = bson.D{{"$match", bson.D{
{"user_id", userID},
{"$text", bson.D{{"$search", search}}},
}}}
but this will search the users table but what I want to search is the members table I just joined in the lookup, how do i achieve this please?