$center¶
-
$center¶ New in version 1.4.
This specifies a circle shape for the
$withinoperator in geospatial queries. To define the bounds of a query using$center, you must specify:- the center point, and
- the radius
Considering the following example:
The above command returns all the documents that fall within a 10 unit radius of the point
[0,0].Changed in version 2.2.3: Before 2.2.3, a geospatial index must exist on a field holding coordinates before using any of the geolocation query operators. After 2.2.3, applications may use geolocation query operators without having a geospatial index; however, geospatial indexes will support much faster geospatial queries than the unindexed equivalents.
Note
A geospatial index must exist on a field and the field must hold coordinates before you can use any of the geolocation query operators.