I have a mongo pipeline. Here is the output of one of the steps.
{
"_id": "6249b7a8338c31b803a1e56b",
"sentences": [
66,
61,
98,
44
],
"documents": [
{
"sentences": [
{
"uuid": 66,
"text": "cbElZuplrxPQicnBHvKQutEhZ",
"index": 58,
"cluster_id": "PyYvsHQfnypoowYsswiAJLlFP"
},
{
"uuid": 61,
"text": "cbElZuplrxPQicnBHvKQutEhZ",
"index": 58,
"cluster_id": "PyYvsHQfnypoowYsswiAJLlFP"
}
]
}
]
}
In one of the steps, I need to filter the array $documents.sentences based on whether the $documents.sentences.uuid is in $sentences. My pipeline $project stage is defined like this:
{
"sentences": 1,
"documents.sentences": {
$filter: {
"input": "$documents.sentences",
"as": "s",
"cond": {
$in: ["$$s.uuid", "$sentences"],
}}
}
}
However, this results in a completely empty $documents
My question is, what is the best way to filter the documents.sentences array based on the condition, if documents.sentences.uuid is in sentences?
thank you for your time