New in version 2.6.
Takes two or more arrays and returns an array containing the elements that appear in any input array.
$setUnionhas the following syntax:
$setUnion 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,
$setUnion 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
$setUnion operator to return an array of elements found in the
A array or the
B array or both:
The operation returns the following results: