MongoDB Questions and Answers – Geospatial Index

«
»

This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Geospatial Index”.

1. ___________ selects geometries that intersect with a GeoJSON geometry.
a) $near
b) $nearsphere
c) $geoIntersect
d) None of the mentioned
View Answer

Answer: c
Explanation: The 2dsphere index supports $geoIntersects.

2. Point out the wrong statement.
a) If $near or $nearSphere query specifies the center point as a GeoJSON point, specify the distance as a non-negative number in meters
b) If $nearSphere query specifies the center point as legacy coordinate pair, specify the distance as a non-negative number in radians
c) $near can only use the 2dsphere index if the query specifies the center point as a GeoJSON point
d) None of the mentioned
View Answer

Answer: d
Explanation:$minDistance filters the results of a geospatial $near or $nearSphere query to those documents that are at least the specified distance from the center point.

advertisement

3. _______ returns geospatial objects in proximity to a point.
a) $near
b) $nearsphere
c) $geoIntersect
d) None of the mentioned
View Answer

Answer: a
Explanation:$near requires a geospatial index.

4. _________ specifies a geometry in GeoJSON format to geospatial query operators.
a) $sphere
b) $geoin
c) $geometry
d) All of the mentioned
View Answer

Answer: c
Explanation:$geometry uses EPSG:4326 as the default coordinate reference system (CRS).

advertisement
advertisement

5. Point out the correct statement.
a) Both 2dsphere and 2d geospatial indexes support $geoWithin
b) $geoWithin does not require a geospatial index
c) The $geoWithin operator does not return sorted results
d) None of the mentioned
View Answer

Answer: b
Explanation: However, a geospatial index will improve query performance.

6. _________ returns geospatial objects in proximity to a point on a sphere. Requires a geospatial index.
a) $near
b) $nearsphere
c) $geoIntersect
d) None of the mentioned
View Answer

Answer: b
Explanation: The 2dsphere and 2d indexes support $nearSphere.

Become Top Ranker in MongoDB Now!
advertisement

7. __________ specifies a minimum distance to limit the results of $near and $nearSphere queries.
a) $center
b) $maxDistance
c) $minDistance
d) All of the mentioned
View Answer

Answer: c
Explanation:$minDistance is available for use with 2dsphere index only.

8. The _________ operator specifies a circle for a $geoWithin query.
a) $within
b) $gwithin
c) $center
d) All of the mentioned
View Answer

Answer: c
Explanation: The query returns legacy coordinate pairs that are within the bounds of the circle.

advertisement

9. ________ index must exist on a field holding coordinates before using any of the geospatial query operators.
a) Unique
b) Geospatial
c) Temporal
d) All of the mentioned
View Answer

Answer: b
Explanation: Only the 2d geospatial index supports $center.

Sanfoundry Global Education & Learning Series – MongoDB.

advertisement

Here’s the list of Best Books in MongoDB.

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 & technical discussions at Telegram SanfoundryClasses.