Basic Aggregation - Utility Stages

{$setIntersection : ["$cast", “$favorites”]} - this is returning null instead of an array. what am I missing here?

Is favorites an array? Are there matching elements? And have you looked at all the records?

yes. favorites is an array, which is user declared and not part of the document!
So, i did a project of “cast” from the document and favorites. there are matching elements in both the arrays, which i have verified. Now when i do the intersection, the output type is a null array.

when i do {$setIntersection : ["$cast", “$favorites”]} and {$setIntersection : [ “$favorites”, “$cast”]} i m getting a null array

??

Or pick a _id that you know has matching elements and filter down to that specific document to check if it returns an intersection. Or add an additional match stage to only return documents with non-null values on the intersection.

Resolved the issue. I dint verify previously that favorites was still $in cast