MongoDB Questions and Answers – Pipeline and Sharded Collections

This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Pipeline and Sharded Collections”.

1. Which of the following returns a substring of a string?
a) $subs
b) $substring
c) $substr
d) None of the mentioned
View Answer

Answer: c
Explanation: $substr accepts three expressions as arguments: the first argument must resolve to a string, and the second and third arguments must resolve to integers.

2. Point out the correct statement.
a) $substr ends at a specified index position up to a specified length
b) $toLower converts a string to lowercase
c) $gtle returns true if the first value is greater than or equal to the second
d) All of the mentioned
View Answer

Answer: b
Explanation: If the argument resolves to null, $toLower returns an empty string “”.

3. Which of the following accepts a single argument expression?
a) $toLow
b) $toUpper
c) $toEqual
d) None of the mentioned
View Answer

Answer: b
Explanation: $toUpper converts a string to uppercase.

advertisement
advertisement

4. Which of the following performs case-insensitive string comparison?
a) $strcasecmpequals
b) $strcasecmp
c) $strcmp
d) None of the mentioned
View Answer

Answer: a
Explanation: $strcasecmp returns 0 if two strings are equivalent.

5. Point out the wrong statement.
a) { $meta: “textScore” } expression is only meaningful in a pipeline that includes a $match stage with a $text query
b) The { $meta: “textScore” } expression is the only expression that the $sort stage accepts
c) $toLower only has a well-defined behavior for strings of ASCII characters
d) None of the mentioned
View Answer

Answer: d
Explanation: A $meta expression has the following syntax:{ $meta: <metaDataKeyword> }.

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

6. _______ is used for access text search metadata.
a) $text
b) $metades
c) $meta
d) All of the mentioned
View Answer

Answer: c
Explanation: $meta returns the metadata associated with a document in a pipeline operations.

7. Which of the following accepts named parameters?
a) $reduce
b) $letnum
c) $let
d) None of the mentioned
View Answer

Answer: d
Explanation: $let defines variables for use within the scope of a subexpression and returns the result of the subexpression.

advertisement

8. _______ returns the number of elements in the array.
a) $number
b) $size
c) $div
d) None of the mentioned
View Answer

Answer: b
Explanation: The argument for $size can be any expression as long as it resolves to an array.

9. _________ returns a value without parsing.
a) $string
b) $literal
c) $characters
d) None of the mentioned
View Answer

Answer: b
Explanation: Use for values that the aggregation pipeline may interpret as an expression.

advertisement

10. db.collection.aggregate() returns a _______ and can return result sets of any size.
a) replica
b) cursor
c) document
d) $subtract
View Answer

Answer: b
Explanation: The aggregate command can return results as a cursor or store the results in a collection, which are not subject to the size limit.

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.