Docs HomeMongoDB Manual

Geospatial Query Operators地理空间查询运算符

On this page本页内容

Geospatial operators return data based on geospatial expression conditions.地理空间运算符根据地理空间表达式条件返回数据。

Note

For details on a specific operator, including syntax and examples, click on the link to the operator's reference page.有关特定运算符的详细信息,包括语法和示例,请单击该运算符参考页的链接。

Operators运算符

Query Selectors查询选择器

Name名称Description描述
$geoIntersectsSelects geometries that intersect with a GeoJSON geometry. 选择与GeoJSON几何体相交的几何体。The 2dsphere index supports $geoIntersects.2dsphere索引支持$geoIntersects
$geoWithinSelects geometries within a bounding GeoJSON geometry. 选择边界GeoJSON几何体中的几何体。The 2dsphere and 2d indexes support $geoWithin.2dsphere索引和2d索引支持$geoWithin
$nearReturns geospatial objects in proximity to a point. 返回点附近的地理空间对象。Requires a geospatial index. 需要地理空间索引。The 2dsphere and 2d indexes support $near.2dsphere索引和2d索引支持$near
$nearSphereReturns geospatial objects in proximity to a point on a sphere. 返回球体上某个点附近的地理空间对象。Requires a geospatial index. 需要地理空间索引。The 2dsphere and 2d indexes support $nearSphere.2dsphere索引和2d索引支持$nearSphere

Geometry Specifiers几何体规范

Name名称Description描述
$boxSpecifies a rectangular box using legacy coordinate pairs for $geoWithin queries. $geoWithin查询指定一个使用旧坐标对的矩形框。The 2d index supports $box.2d索引支持$box
$centerSpecifies a circle using legacy coordinate pairs to $geoWithin queries when using planar geometry. 使用平面几何图形时,使用旧坐标对将圆指定为$geoWithin查询。The 2d index supports $center.2d索引支持$center
$centerSphereSpecifies a circle using either legacy coordinate pairs or GeoJSON format for $geoWithin queries when using spherical geometry. 使用球形几何体时,为$geoWithin查询指定使用传统坐标对或GeoJSON格式的圆。The 2dsphere and 2d indexes support $centerSphere.2dsphere索引和2d索引支持$centerSphere
$geometrySpecifies a geometry in GeoJSON format to geospatial query operators.为地理空间查询运算符指定GeoJSON格式的几何体。
$maxDistanceSpecifies a maximum distance to limit the results of $near and $nearSphere queries. 指定最大距离以限制$near$nearSphere查询的结果。The 2dsphere and 2d indexes support $maxDistance.2dsphere2d索引支持$maxDistance
$minDistanceSpecifies a minimum distance to limit the results of $near and $nearSphere queries. For use with 2dsphere index only.指定限制$near$nearSphere查询结果的最小距离。仅用于2dsphere索引。
$polygonSpecifies a polygon to using legacy coordinate pairs for $geoWithin queries. 指定要为$geoWithin查询使用旧坐标对的多边形。The 2d index supports $center.2d索引支持$center