Indexindexing Concepts(Engineering > Computer Science And Engineering > Mongodb ) Questions and Answers
Question 1. Point out the correct statement :
Both 2dsphere and 2d geospatial indexes support $geoWithin
$geoWithin does not require a geospatial index
The $geoWithin operator does not return sorted results
None of the mentioned
Explanation:-
Answer: Option B. -> $geoWithin does not require a geospatial index
However, a geospatial index will improve query performance.
Question 2. To terminate an ongoing index build, use the __________ method in the mongo shell.
db.currentOp()
db.killOp()
db.removeOp()
All of the mentioned
Explanation:-
Answer: Option B. -> db.killOp()
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.
Question 3. The background task that removes expired documents runs every ________ seconds.
15
45
60
120
Explanation:-
Answer: Option C. -> 60
As a result, documents may remain in a collection during the period between the expiration of the document and the running of the background task.
Question 4. The _________ property for an index causes MongoDB to reject duplicate values for the indexed field.
Hashed
Unique
Multikey
None of the mentioned
Explanation:-
Answer: Option C. -> Multikey
Other than the unique constraint, unique indexes are functionally interchangeable with other MongoDB indexes.
Question 5. For a _____ multikey index, each indexed document can have at most one indexed field whose value is an array.
Hashed
Unique
Multikey
compound
Explanation:-
Answer: Option D. -> compound
As such, you cannot create a compound multikey index if more than one to-be-indexed field of a document is an array.
Question 6. The $geoWithin operator uses the _______ operator to specify the GeoJSON object.
$sphere
$geoin
$geometry
All of the mentioned
Explanation:-
Answer: Option C. -> $geometry
For $geoWithin, if you specify a single-ringed polygon that has an area greater than a single hemisphere, include the custom MongoDB coordinate reference system in the $geometry expression.
Question 7. Point out the correct statement :
Applications can use $center without having a geospatial index
Before 3.0, a geospatial index must exist on a field holding coordinates before using any of the geospatial query operators
To use $centerSphere, specify an array that contains grid coordinates of the circle's center point
None of the mentioned
Explanation:-
Answer: Option A. -> Applications can use $center without having a geospatial index
However, geospatial indexes support much faster queries than the unindexed equivalents.
Question 8. The ______ index is unique and prevents clients from inserting two documents with the same value for the _id field.
_id
$default
_def
None of the mentioned
Explanation:-
Answer: Option A. -> _id
All MongoDB collections have an index on the _id field that exists by default.
Question 9. __________ method provides a wrapper around the totalIndexSize output of the collStats (i.e. db.collection.stats()) operation.
db.collection.totalallIndexSize()
db.collection.totalIndexSizeAll()
db.collection.totalIndexSize()
All of the mentioned
Explanation:-
Answer: Option C. -> db.collection.totalIndexSize()
To check the size of your indexes, use the db.collection.totalIndexSize() helper, which returns data in bytes.
Question 10. Point out the correct statement :
After 2.4, you can terminate both background index builds and foreground index builds
The specified language in the document overrides the default language for the text index
The text index, like other indexes,should not fall within the index name length limit
None of the mentioned
Explanation:-
Answer: Option B. -> The specified language in the document overrides the default language for the text index
To get the names of the indexes, use the db.collection.getIndexes() method.