MongoDB Questions and Answers – Indexing Methods

«
»

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

Answer: a
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

Answer: b
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.

advertisement

3. _________ defines a circle for a geospatial query that uses spherical geometry.
a) $center
b) $centre
c) $radii
d) $centersphere
View Answer

Answer: d
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

Answer: b
Explanation: To use the $box operator, you must specify the bottom left and top right corners of the rectangle in an array object.

advertisement
advertisement

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

Answer: a
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

Answer: d
Explanation: The query returns documents that are within the bounds of the circle.

advertisement

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

Answer: b
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

Answer: b
Explanation: The $polygon operator calculates distances using flat (planar) geometry.

advertisement

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

Answer: a
Explanation: Geospatial queries no longer return duplicate results.

Sanfoundry Global Education & Learning Series – MongoDB.

advertisement

Here’s the list of Best Reference Books in MongoDB.

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!
advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter