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.

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.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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 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.