C100DEV Indexing Practice Question
You are storing GPS coordinates in a 'locations' collection using GeoJSON format. You need to perform queries that find points within a specific polygon. Which index type must be created on the location field?
⚠ Common exam trap
Students frequently confuse 2d and 2dsphere index types, mistakenly applying planar 2d indexes to spherical GeoJSON coordinate data.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
A '2dsphere' index to support GeoJSON and spherical geometry.
For querying data on a sphere (like the Earth), MongoDB provides the '2dsphere' index. This index type supports GeoJSON objects and calculates distances using spherical geometry. It is required for advanced geospatial queries such as $geoWithin or $nearSphere when working with real-world coordinates and complex shapes like polygons.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
A '2d' index, as it is the standard for all geospatial data.
Why it's wrong here
The '2d' index is designed for data on a flat, Euclidean plane (like a game map or a CAD drawing). While it can store coordinate pairs, it does not support GeoJSON polygons or spherical calculations, making it inappropriate for accurate Earth-based GPS queries that involve complex shapes.
- ✓
A '2dsphere' index to support GeoJSON and spherical geometry.
Why this is correct
The '2dsphere' index is specifically built for Earth-like spherical geometry. It supports GeoJSON points, line strings, and polygons. This index is necessary for executing queries that determine if a point exists within a geographical boundary (polygon) while accounting for the curvature of the Earth.
- ✗
A standard ascending index, as GeoJSON is just a nested document.
Why it's wrong here
While GeoJSON is a subdocument, a standard B-tree index only supports exact matches or range matches on the literal values. It does not understand spatial relationships or geometry. Without a '2dsphere' index, geospatial operators like $geoWithin will fail to execute because they lack the necessary spatial indexing support.
- ✗
A 'geo' index, which automatically chooses between 2d and 2dsphere.
Why it's wrong here
There is no index type simply called 'geo'. Developers must explicitly choose between '2d' and '2dsphere' based on their data format and the geometry of the space they are indexing. Using the wrong type will result in either query errors or inaccurate results for geographical calculations.
About these practice questions
One of 259 original C100DEV practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official MongoDB exam blueprint
This C100DEV practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DEV exam.