Aggregation $match on $or value

I have an aggregation pipeline setup but I’m having trouble with this one part. Here is what I’m trying to do:

  • targetGender is an array of genders
  • I want to check if this array contains either the uppercase version or the lowercase version of my local gender variable
  • I want to return documents that have either value in it

This is what I currently have which doesnt work. I’ve tried it multiple ways and none of them have worked so please let me know how I can accomplish this!

Why is there “$” in front of “target_gender field?

Also it’s hard to tell in the screenshot but are all those brackets {} cause they look like []…

2 Likes

This is actually written in swift hence the square brackets. And thank you for catching the $ in front of targetGender, I was moving around so much code I might’ve put it there accidentally. Upon removing the $, it seems to work!

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.