The behavior of Geo indexes is inconsistent and is not enforced by the code.
The ensureIndex() command will let you create multiple 2d and 2dsphere indexes on a collection.
If you query the collection with $geoNear, it will error out if there are multiple 2d indexes, and will silently ignore the 2dsphere index if there is both a 2d and a 2dsphere index
If you query a collection with $nearSphere, you can use a collection with multiple 2d indexes; the index selected for the query depends on the query field specified in $nearSphere.
This should be made (at the least) consistent; ideally MongoDB should:
- Support multiple Geo indexes on a single collection
- Allow the $geoNear command to specify which field to use for the query (in the same way that the $nearSphere command does
If MongoDB is going to have a limit of one Geo index per collection, it should enforce that limit when ensureIndex() is called, and not when the collection is queried.
EDIT: Radically revised problem description