This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Index Management”.
1. To modify an existing index, you cannot just re-issue the _________ method with the updated specification of the index.
a) dropIndex()
b) modIndex()
c) createIndex()
d) none of the mentioned
View Answer
Explanation: To modify the index, you must drop the index first.
2. Point out the wrong statement.
a) To modify an existing index, you need to drop and recreate the index
b) Your client library may have a different or additional interface for this operation
c) To see the status of an indexing process, you can use the db.statusOp() method in the mongo shell
d) None of the mentioned
View Answer
Explanation: To see the status of an indexing process, you can use the db.currentOp() method in the mongo shell.
3. If you need to rebuild indexes for a collection you can use the _________ method to rebuild all indexes on a collection in a single operation.
a) db.collection.Index()
b) db.collection.reIndex()
c) db.collection.rebuildIndex()
d) none of the mentioned
View Answer
Explanation: This operation drops all indexes, including the _id index, and then rebuilds all indexes.
4. To terminate an ongoing index build, use the __________ method in the mongo shell.
a) db.currentOp()
b) db.killOp()
c) db.removeOp()
d) all of the mentioned
View Answer
Explanation: For index builds, the effects of db.killOp() may not be immediate and may occur well after much of the index build operation has completed.
5. Point out the correct statement.
a) After 4.0, you cannot terminate both background index builds and foreground index builds
b) Before MongoDB 2.1, you could only terminate background index builds
c) After 2.4, you can terminate both background index builds and foreground index builds
d) None of the mentioned
View Answer
Explanation: You cannot terminate a replicated index build on secondary members of a replica set.
6. In the mongo shell, you can use the ______ method to return a list of the indexes on a collection.
a) getallIndexes()
b) getretIndexes()
c) getIndexes()
d) none of the mentioned
View Answer
Explanation: When performing maintenance you may want to check which indexes exist on a collection.
7. __________ views partial execution statistics collected during plan selection.
a) curs.explain()
b) cursor.explain()
c) cursr.explain()
d) all of the mentioned
View Answer
Explanation: Run db.collection.explain() or the cursor.explain() method in allPlansExecution mode.
8. The __________ operator constrains the results of a geospatial $near or $nearSphere query to the specified distance.
a) $center
b) $maxDistance
c) $minDistance
d) all of the mentioned
View Answer
Explanation: The measuring units for the maximum distance are determined by the coordinate system in use.
9. To force MongoDB to use a particular index for a db.collection.________ operation, specify the index with the hint() method.
a) query()
b) find()
c) index()
d) all of the mentioned
View Answer
Explanation: Append the hint() method to the find() method.
10. Specify the ______ operator to the hint() method to prevent MongoDB from using any index.
a) $unique
b) $natural
c) $spatial
d) all of the mentioned
View Answer
Explanation: To view the execution statistics for a specific index, append to the db.collection.find() the hint() method followed by cursor.explain().
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Apply for Programming Internship
- Check Information Technology Books
- Apply for MongoDB Internship
- Practice Programming MCQs
- Check MongoDB Books