对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

$maxDistance(查询谓词运算操作符)

$maxDistance

The $maxDistance operator constrains the results of a geospatial $near or $nearSphere query to the specified distance. The measuring units for the maximum distance are determined by the coordinate system in use. For GeoJSON point objects, specify the distance in meters, not radians. You must specify a non-negative number for $maxDistance.

2dsphere2 d地理空间索引均支持 $maxDistance:。

以下示例查询返回位置值距离点[ -74 , 40 ]不超过10个单位的文档。

db.places.find( {
loc: { $near: [ -74 , 40 ], $maxDistance: 10 }
} )

MongoDB 按与[ -74 , 40 ]的距离对结果进行排序。 除非您使用cursor.limit()方法修改查询,否则该操作将返回前 100 个结果。

给本页内容打分

在此页面上