The $geoNear aggregation operator supports geospatial operations within the context of the aggregation framework. The $geoNear operator can be used to form a new pipeline stage, upon which geospatial data comes into play. In this case, documents are placed in the pipeline by the indicated GeoJSON field in order of nearest to furthest from a given point.
Here is a brief summary of the more important parameters available for this operator:
Option | Notes |
near | If the field used has a 2dsphere index, you can use either a GeoJSON object of the point type or a list of legacy coordinate pairs (for example, [ <longitude>,<latitude>]) as an argument. On the other hand, if the field only has a flat 2D index, you can only supply a legacy coordinate pair list as an argument. |
spherical | When set to True, this parameter forces MongoDB to use a spherical model of calculation. Otherwise, if set to the default... |