• $center (defines a circle) MongoDB Documentation, Release 3.0.4 MongoDB supports rudimentary spherical queries on flat 2d indexes for legacy reasons. In general, spherical calcula- tions should use a 2dsphere index, as described in 2dsphere Indexes (page 496). To query for legacy coordinate pairs in a “spherical cap” on a sphere, use $geoWithin with the $centerSphere operator. Specify an array that contains: Use the following syntax: The following example query returns all documents within a 10-mile radius of longitude 88 W and latitude 30 N . The example converts distance to radians by dividing distance by the approximate equatorial radius of the earth, 3963.2 miles: Proximity queries return the 100 legacy coordinate pairs closest to the defined point and sort the results by distance. Use either the $near operator or geoNear command. Both require a 2d index. The $near operator uses the following syntax: For examples, see $near . The geoNear command uses the following syntax: The geoNear command offers more options and returns more information than does the $near operator. To run the command, see geoNear . Changed in version 2.6: Previously, 2d indexes would support exact-match queries for coordinate pairs. You cannot use a 2d index to return an exact match for a coordinate pair. Use a scalar, ascending or descending, index on a field that stores coordinates to return exact matches. 535 8.3. Indexing Tutorials Exact Matches on a Flat Surface Points within a Circle Defined on a Sphere db.<collection>.find( { <location field> : { $geoWithin : { $centerSphere : [ [ <x>, <y> ] , <radius> ] } } } ) • The grid coordinates of the circle’s center point • The circle’s radius measured in radians. To calculate radians, see Calculate Distance Using Spherical Geometry (page 537). Proximity to a Point on a Flat Surface db.<collection>.find( { loc : { $geoWithin : { $centerSphere : [ [ 88 , 30 ] , 10 / 3963.2 ] } } } ) db.<collection>.find( { <location field> : { $near : [ <x> , <y> ] } } ) db.runCommand( { geoNear: <collection>, near: [ <x> , <y> ] } )