Complete the code to start an aggregation pipeline with the correct stage operator.
db.collection.aggregate([[1]])The $match stage filters documents and is commonly the first stage in a pipeline for optimization.
Complete the code to optimize the pipeline by placing the correct stage early.
db.collection.aggregate([[1], { $group: { _id: '$category', total: { $sum: '$price' } } }])
$project before filtering, which does not reduce documents.Placing $match early filters documents, reducing the workload for later stages.
Fix the error in the pipeline by choosing the correct stage operator.
db.collection.aggregate([{ $match: { status: 'A' } }, [1]])$filter as a pipeline stage, which is an expression, not a stage.$unwind incorrectly without context.The $group stage correctly aggregates documents after filtering with $match.
Fill both blanks to optimize the pipeline by filtering and projecting fields.
db.collection.aggregate([[1], [2]])
First, $match filters documents, then $project selects fields to keep, optimizing data flow.
Fill all three blanks to build an optimized pipeline with filtering, unwinding, and grouping.
db.collection.aggregate([[1], [2], [3]])
The pipeline filters documents with $match, expands array elements with $unwind, then groups by tags with $group.