I would like to do a $regex search against regex values in another collection. With SQL I would use a subquery and "like" - but I'm unsure if there is an equivalent structure/query to do something like this. I know this is not correct, but I'm picturing something like this - just not sure of the correct syntax - especially to indicate the specific column to do the regex against:
{
company: {
$in: [{
"$regex": {"collName":"SavedSearches", "include":"search",
"owner":"5278ef66e4b01085e4b79482"},
"$options": "im"
}]
}
}
where SavedSearches has 3 columns:
_id
owner (user id - each user may have multiple saved searches)
search (string containing regex expression to search for)
_id owner search
5432e856e4b013192ec44d30 5278ef66e4b01085e4b79482 googl
54401e92e4b05c4ac3b7be7c 5278ef66e4b01085e4b79482 appl
So the query would return rows for companies including "Google" and "Apple" and "Snapple".
Is this possible? If not, I'm thinking I will have to store saved searches in an array and build the query on the fly using "$in array of $regex". But i would prefer to do a "subquery" style approach where I could potentially search for matches across multiple users using a job and pushnotification.
thanks in advance.