MongoDB Documentation, Release 3.0.4 For sharded collections, queries using $near and $nearSphere are not supported. You can instead use either the geoNear command or the $geoNear aggregation stage. You can also query for geospatial data using $geoWithin . The following pages provide complete documentation for geospatial indexes and queries: 2dsphere Indexes New in version 2.4. Overview A 2dsphere index supports queries that calculate geometries on an earth-like sphere. 2dsphere index supports all MongoDB geospatial queries: queries for inclusion, intersection and proximity. See the http://docs.mongodb.org/manual/reference/operator/query-geospatial for the query op- erators that support geospatial queries. The 2dsphere index supports data stored as GeoJSON (page 553) objects and as legacy coordinate pairs (See also 2dsphere Indexed Field Restrictions (page 497)). For legacy coordinate pairs, the index converts the data to GeoJSON Point (page 553). For details on the supported GeoJSON objects, see GeoJSON Objects (page 553). The default datum for an earth-like sphere is WGS84 . Coordinate-axis order is longitude, latitude . 2dsphere (Version 2) Changed in version 2.6. MongoDB 2.6 introduces a version 2 of 2dsphere indexes. Version 2 is the default version of 2dsphere indexes created in MongoDB 2.6 and later series. To override the default version 2 and create a version 1 index, include the option { "2dsphereIndexVersion": 1 } when creating the index. 2dsphere (Version 2) indexes are sparse (page 505) by default and ignores the sparse: true (page 505) option. If a document lacks a 2dsphere index field (or the field is null or an empty array), MongoDB does not add an entry for the document to the index. For inserts, MongoDB inserts the document but does not add to the 2dsphere index. sparse Property Changed in version 2.6. For a compound index that includes a 2dsphere index key along with keys of other types, only the 2dsphere index field determines whether the index references a document. Earlier versions of MongoDB only support 2dsphere (Version 1) indexes. 2dsphere (Version 1) in- dexes are not sparse by default and will reject documents with null location fields. Additional GeoJSON Objects 2dsphere (Version 2) includes support for additional GeoJSON object: MultiPoint (page 554), MultiLineString (page 555), MultiPolygon (page 555), and GeometryCollection (page 556). For details on all supported GeoJSON objects, see GeoJSON Objects (page 553). Chapter 8. Indexes 496 2dsphere Indexes (page 496) A 2dsphere index supports queries that calculate geometries on an earth-like sphere. The index supports data stored as both GeoJSON objects and as legacy coordinate pairs. 2d Indexes (page 497) The 2d index supports data stored as legacy coordinate pairs and is intended for use in Mon- goDB 2.2 and earlier. geoHaystack Indexes (page 498) A haystack index is a special index optimized to return results over small areas. For queries that use spherical geometry, a 2dsphere index is a better option than a haystack index. 2d Index Internals (page 499) Provides a more in-depth explanation of the internals of geospatial indexes. This ma- terial is not necessary for normal operations but may be useful for troubleshooting and for further understanding. Additional Resources