MongoDB geospatial query operators are used to perform queries based on geographical or spatial sets of coordinates. As noted previously, only two operators support the flat model; however, all geospatial operators support the spherical model. Here is a brief summary of the MongoDB geospatial query operators:
Operator | Spherical | Flat | Notes |
$near | Y | Y | Returns documents in order of nearest to furthest from the point specified using the $geometry parameter. You can also supply two additional parameters, $minDistance and $maxDistance, in order to limit the number of documents returned. You can use either a 2D or a 2Dsphere index. |
$nearSphere | Y | N | Operates exactly like $near, but uses a 2Dsphere index and only follows the spherical model. |
$geoWithin | Y | Y | Accepts a $geometry argument with type and coordinates keys. The type can be either Polygon or MultiPolygon. |
$geoIntersects | Y | N | This operator accepts the same arguments and keys as $geoWithin... |