Is there a way I can build an aggregation pipeline stage to do a $regexMatch on an object field nested within another object. I typically see examples using the $addFields aggregation pipeline stage, so I've been trying to do a match with this stage. I'm trying to do a search on the word word within the string_text field of each object.
Note: This needs to be done in the domain file when building the aggregation pipeline.
Here is an example of the data I'm trying to do a $regexMatch on, in this case the text field:
{
array_of_data: [
textObjects: {
text1: {
string_text: "Matching word here"
},
text2: {
string_text: "Looking for the matching word which is here"
},
text3: {
string_text: "Won't find it here"
}
}
]
}
I've been trying to build it solve this issue with a $filter operation, but still don't get the results I'm looking for, it returns every document and not the ones with the word word in the string_text field.
Any help would be appreciated, I've been struggling with this for a few days now :(