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

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

$box

Specifies a rectangle for a geospatial $geoWithin query to return documents that are within the bounds of the rectangle, according to their point-based location data. When used with the $box operator, $geoWithin returns documents based on grid coordinates and does not query for GeoJSON shapes.

To use the $box operator, you must specify the bottom left and top right corners of the rectangle in an array object:

{
<location field>: {
$geoWithin: {
$box: [
[ <bottom left coordinates> ],
[ <upper right coordinates> ]
]
}
}
}

重要

如果使用经度和纬度,请先指定经度。

查询用平面几何图形计算距离。

Applications can use $box without having a geospatial index. However, geospatial indexes support much faster queries than the unindexed equivalents.

Only the 2d geospatial index supports $box.

以下示例查询返回框中具有以下点的所有文档:[ 0 , 0 ]、[ 0 , 100 ]、[ 100 , 0 ] 和 [ 100 , 100 ]。

db.places.find( {
loc: { $geoWithin: { $box: [ [ 0, 0 ], [ 100, 100 ] ] } }
} )
给本页内容打分

在此页面上