New in version 2.6.
Takes two or more arrays and returns an array that contains the elements that appear in every input array.
$setIntersectionhas the following syntax:
$setIntersection performs set operation on arrays, treating arrays as sets. If an array contains duplicate entries,
$setIntersection ignores the duplicate entries.
$setIntersection ignores the order of the elements.
$setIntersection filters out duplicates in its result to output an array that contain only unique entries. The order of the elements in the output array is unspecified.
If a set contains a nested array element,
$setIntersection does not descend into the nested array but evaluates the array at top-level.
experiments collection with the following documents:
The following operation uses the
$setIntersection operator to return an array of elements common to both the
A array and the
The operation returns the following results: