This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Indexing Methods”.
1. __________ query calculates distances using flat (planar) geometry.
a) $center
b) $centre
c) $radii
d) Sort
View Answer
Explanation: In MongoDB, sort operations can obtain the sort order by retrieving documents based on the ordering in an index.
2. Point out the wrong statement.
a) The query scans the index and not the collection
b) If overall selectivity is high, and if MongoDB must read a number of documents to return results, then some queries may perform faster without indexes
c) A better strategy, depending on your queries, would be to create a compound index that includes the high-selectivity field and another field
d) None of the mentioned
View Answer
Explanation: To ensure selectivity, write queries that limit the number of possible documents with the indexed field. Write queries that are appropriately selective relative to your indexed data.
3. _________ defines a circle for a geospatial query that uses spherical geometry.
a) $center
b) $centre
c) $radii
d) $centersphere
View Answer
Explanation: You can use the $centerSphere operator on both GeoJSON objects and legacy coordinate pairs.
4. When used with the $box operator, _________ returns documents based on grid coordinates and does not query for GeoJSON shapes.
a) $geoNear
b) $geoWithin
c) $geoRear
d) All of the mentioned
View Answer
Explanation: To use the $box operator, you must specify the bottom left and top right corners of the rectangle in an array object.
5. Point out the correct statement.
a) Applications can use $center without having a geospatial index
b) Before 3.0, a geospatial index must exist on a field holding coordinates before using any of the geospatial query operators
c) To use $centerSphere, specify an array that contains grid coordinates of the circle’s center point
d) None of the mentioned
View Answer
Explanation: However, geospatial indexes support much faster queries than the unindexed equivalents.
6. Applications can use _________ without having a geospatial index.
a) $center
b) $centre
c) $radii
d) $centersphere
View Answer
Explanation: The query returns documents that are within the bounds of the circle.
7. _________ specifies a polygon for a geospatial $geoWithin query on legacy coordinate pairs.
a) $rect
b) $polygon
c) $poly
d) All of the mentioned
View Answer
Explanation: To define the polygon, specify an array of coordinate points.
8. Only the ______ geospatial index supports the $polygon operator.
a) 1dsphere
b) 2d
c) 3d
d) None of the mentioned
View Answer
Explanation: The $polygon operator calculates distances using flat (planar) geometry.
9. ________ returns a document only once for a geospatial query even if the document matches the query multiple times.
a) $uniqueDocs
b) $unique
c) $Docs
d) All of the mentioned
View Answer
Explanation: Geospatial queries no longer return duplicate results.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Check Information Technology Books
- Practice Programming MCQs
- Apply for Programming Internship
- Check MongoDB Books