Full text search in multiple collections

Hello everybody, I have a question about Atlas Search:

For example given these collections:

    Post:
    {
     _id: ObjectId,
     text: String,
     _comments: [ Comment ],
     _author: [ User ],
    }
    Comment:
    {
     _id: ObjectId,
     text: String,
     _subComments: [ Comment ],
     _author: [ User ],
     _post: Post
    }
    User:
    {
     _id: ObjectId,
     name: {
             firstName: String,
             lastName: String,
           }
    }

Is it possible to do a full text search for Posts where the text match the query, OR its Comments text match the query, OR the Post author (User) full name (firstName + lastName) matches the query, OR the Comments author full name matches the query?

Basically searching for multiple collections within one search, and generate a match score based on number of matches and accuracy.

If this is not possible, do you know if this is possible with a third party service?

Thanks!

2 Likes

I have the same question… some direction please.

Thanks

Bumping this post up! I have the same query.

I also have this question.

Is mongo planning on adding multiple-collection $search to Atlas full-text $search?

Please review the How to Run Queries Across Collections documentation for Atlas Search.

Please note that you’ll need a cluster running MongoDB 6.0 or higher to specify the Atlas Search $search or $searchMeta stage in the $unionWith and $lookup pipeline stages.