This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Aggregation Operations”.
1. _______ filters the document stream to allow only matching documents to pass unmodified into the next pipeline stage.
a) $regex
b) $reg
c) $match
d) None of the mentioned
View Answer
Explanation: $match uses standard MongoDB queries. For each input document, outputs either one document (a match) or zero documents (no match).
2. Point out the wrong statement.
a) Documents do not pass through the stages in sequence
b) Pipeline stages appear in an multi dimensional array
c) $project reshapes each document in the stream, such as by adding new fields or removing existing fields
d) All of the mentioned
View Answer
Explanation: For each input document, outputs one document.
3. Which of the following can be used to implement field level redaction?
a) $skip
b) $limit
c) $match
d) $redact
View Answer
Explanation: $redact reshapes each document in the stream by restricting the content for each document based on information stored in the documents themselves.
4. ________ passes the first n documents unmodified to the pipeline where n is the specified limit.
a) $skip
b) $limit
c) $match
d) $redact
View Answer
Explanation: For each input document, outputs either one document (for the first n documents) or zero documents (after the first n documents).
5. _______ reorders the document stream by a specified sort key.
a) $skip
b) $limit
c) $sort
d) None of the mentioned
View Answer
Explanation: Only the order changes; the documents remain unmodified.
6. Which of the following operator incorporates the functionality of $match, $sort, and $limit for geospatial data?
a) $geoSpatial
b) $geoNear
c) $geoRear
d) None of the mentioned
View Answer
Explanation: The output documents include an additional distance field and can include a location identifier field.
7. _____ Writes the resulting documents of the aggregation pipeline to a collection.
a) $out
b) $in
c) $output
d) None of the mentioned
View Answer
Explanation: To use the $out stage, it must be the last stage in the pipeline.
8. ________ deconstructs an array field from the input documents to output a document for each element.
a) $unwindelem
b) $unwind
c) $unwin
d) None of the mentioned
View Answer
Explanation: Each output document replaces the array with an element value.
9. Which of the following operator is related to geography of data?
a) $geoSpatial
b) $geoNear
c) $geoRear
d) None of the mentioned
View Answer
Explanation: $geoNear returns an ordered stream of documents based on the proximity to a geospatial point.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Check Information Technology Books
- Apply for Programming Internship
- Practice Programming MCQs
- Check MongoDB Books