From you're example, Comments is an array of documents.
To find all documents containing the word Happy you need to first filter the results.
I haven't tested this, but something like this should find what you need.
db.mycoll.find({Comments.body: /Happy/})
The consideration here are that for large collections finding a string with a string within a sub document is not going to use an index. You could still make mongodb use an index by doing using /^Happy/ meaning that it will find all comments that start with "Happy" - not very useful.
Another approach might be to keep an array of keywords in the parent document, only including those you're interested in - or excluding those your not - then querying would be much more efficient.
Anyway, back to original problem, i guess as you mentioned $unwind, you wanted to also flatten your comment docs.
Something like this should help. Like i said, i haven't tested this, but should point you in right direction.
db.mycoll.aggregate(
{ $match: {Comments.body : /Happy/ } },
{ $project: { _id:1, status, 1, Comments:1} },
{ $unwind: "$Comments"} })
That should return a collection of docs that look like:
{
_id: 1,
status:'published',
Comments : {
"by" : "mallory",
"body" : "this is patently false",
"rating" : 0.3
}
}
You could project again to flatten the comment.
let me know how you get on.
sam