MongoDB Questions and Answers – Aggregation Operations

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

Answer: c
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

Answer: c
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

Answer: d
Explanation: $redact reshapes each document in the stream by restricting the content for each document based on information stored in the documents themselves.

advertisement
advertisement

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

Answer: b
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

Answer: c
Explanation: Only the order changes; the documents remain unmodified.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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

Answer: b
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

Answer: a
Explanation: To use the $out stage, it must be the last stage in the pipeline.
advertisement

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

Answer: c
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

Answer: b
Explanation: $geoNear returns an ordered stream of documents based on the proximity to a geospatial point.

advertisement

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]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.