MongoDB Questions and Answers – Indexes In MongoDB

This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Indexes In MongoDB”.

1. MongoDB indexes use a _______ data structure.
a) Hash
b) Map
c) B-tree
d) All of the mentioned
View Answer

Answer: b
Explanation: MongoDB provides a number of different index types to support specific types of data and queries.

2. Point out the correct statement.
a) If an appropriate index exists for a query, MongoDB cannot use the index to limit the number of documents it must inspect
b) Indexes support the efficient execution of queries in MongoDB
c) The index stores the location of a specific field or set of fields, ordered by the value of the field
d) None of the mentioned
View Answer

Answer: b
Explanation: Without indexes, MongoDB must perform a collection scan.

3. MongoDB supports the creation of user-defined ascending/descending indexes on a ______ field of a document.
a) Single
b) Non Unique
c) Compound
d) None of the mentioned
View Answer

Answer: a
Explanation: If applications do not specify a value for _id the driver or the mongod will create an _id field with an ObjectId value.

4. The ______ index is unique and prevents clients from inserting two documents with the same value for the _id field.
a) _id
b) $default
c) _def
d) None of the mentioned
View Answer

Answer: a
Explanation: All MongoDB collections have an index on the _id field that exists by default.

advertisement
advertisement

5. Point out the wrong statement.
a) MongoDB can return sorted results by using the ordering in the index
b) MongoDB defines indexes at the collection level and supports indexes on any field or sub-field of the documents in a MongoDB collection
c) Fundamentally, indexes in MongoDB is different to indexes in other database systems
d) None of the mentioned
View Answer

Answer: c
Explanation: Indexes are special data structures that store a small portion of the collection’s data set in an easy to traverse form.

6. MongoDB also supports user-defined indexes on multiple fields called ____________
a) compound
b) composite
c) candidate
d) none of the mentioned
View Answer

Answer: a
Explanation: The order of fields listed in a compound index has significance.

Note: Join free Sanfoundry classes at Telegram or Youtube

7. MongoDB uses ______ indexes to index the content stored in arrays.
a) singlekey
b) multikey
c) compkey
d) none of the mentioned
View Answer

Answer: b
Explanation: If you index a field that holds an array value, MongoDB creates separate index entries for every element of the array.

8. ___________ indexes use spherical geometry to return results.
a) 3dsphere
b) 2dsphere
c) 1dsphere
d) none of the mentioned
View Answer

Answer: b
Explanation: To support efficient queries of geospatial coordinate data, MongoDB provides two special indexes.

advertisement

9. MongoDB provides a ________ index type that supports searching for string content in a collection.
a) string
b) text
c) char
d) none of the mentioned
View Answer

Answer: b
Explanation: These text indexes do not store language-specific stop words (e.g. “the”, “a”, “or”) and stem the words in a collection to only store root words.

10. _____ indexes uses planar geometry when returning results.
a) 2d
b) 1d
c) 3d
d) All of the mentioned
View Answer

Answer: a
Explanation: MongoDB computes geohash values for the coordinate pairs within the specified location range and then indexes the geohash values.

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.