## Query Operations 

MongoDB’s geospatial query operators let you query for: 

Inclusion MongoDB can query for locations contained entirely within a specified polygon. Inclusion queries use the $geoWithin operator. 

Both 2d and 2dsphere indexes can support inclusion queries. MongoDB does not require an index for inclusion queries; however, such indexes will improve query performance. 

Intersection MongoDB can query for locations that intersect with a specified geometry. These queries apply only to data on a spherical surface. These queries use the $geoIntersects operator. 

Only 2dsphere indexes support intersection. 

Proximity MongoDB can query for the points nearest to another point. Proximity queries use the $near operator. The $near operator requires a 2d or 2dsphere index. 

## Geospatial Indexes 

MongoDB provides the following geospatial index types to support the geospatial queries. 

2dsphere 2dsphere (page 496) indexes support: 

• Calculations on a sphere 

• GeoJSON objects and include backwards compatibility for legacy coordinate pairs 

• Compound indexes with scalar index fields (i.e. ascending or descending) as a prefix or suffix of the 2dsphere index field 

New in version 2.4: 2dsphere indexes are not available before version 2.4. 

## See also: 

Query a 2dsphere Index (page 531) 

2d 2d (page 497) indexes support: 

• Calculations using flat geometry 

• Legacy coordinate pairs (i.e., geospatial points on a flat coordinate system) 

• Compound indexes with only one additional field, as a suffix of the 2d index field 

## See also: 

Query a 2d Index (page 534) 

## Geospatial Indexes and Sharding 

You cannot use a geospatial index as the shard key index. 

You can create and maintain a geospatial index on a sharded collection if it uses fields other than the shard key fields. 

