I'm trying to do a regex match inside an aggregation pipeline $lookup
So lets assume the following query:
$lookup: {
from: 'some-collection',
let: {
someIds: '$someIds'
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$in: ['$someId', '$$someIds']
},
{
$not: {
$eq: ['$status', 'archived']
}
}
]
}
}
}
]
}
This all works great, i can match on multiple conditions, and it works.
However if i want to add another condition using an array of regex i can't get it to work
$lookup: {
from: 'some-collection',
let: {
someIds: '$someIds'
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$in: ['$someId', '$$someIds']
},
{
$not: {
$eq: ['$status', 'archived']
}
},
{
$in: ['$some-type', [/type1/, /type2/]]
}
]
}
}
}
]
}
Why does this not work? as i understand it from the documentation i should be able to use regex this way inside an $in
operator, and i can confirm that it works, since we use it elsewhere. However nested within a $lookup
pipeline it does not.
Is this a bug or am i overlooking something? Is there another way i can do this kind of regex match?