$match vs $filter, $project vs $map, $group vs $reduce
Four pairs of operators that get confused constantly. In each pair the difference is the same question: does this act on documents, or on the elements inside one document?
$match vs $filter
$match
Filters documents.
$filter
Filters elements inside an array.
$project vs $map
$project
Transforms a document.
$map
Transforms every element inside an array.
$group vs $reduce
$group
Combines multiple pipeline documents.
$reduce
Combines/reduces elements inside one array.
$map vs $unwind
$map
Keep array structure.
Transform elements.
$unwind
Destroy/flatten array structure.
Each element becomes a pipeline document.