3

我在查询匹配边界框内的项目时遇到问题。我在 mongo文档中阅读了很多但没有成功$box$geoWithin但无法弄清楚为什么查询框中的项目没有产生。

这里有一个来自定义的模式的例子,里面有一个项目和查询来把它拿出来

schemadefinition 看起来像这样,它的验证正在工作。

/**
 * Media location values (Point, LineString, Polygon)
 * @property location
 * @type {Object}
 */
 location:{
            "type":Object,
            "index":"2dsphere"
 },

里面的一项看起来像这样(这是查询的结果):

{
    "_account": "52796da308d618090b000001",
    "_id": "5280d9c6592dce2d36000001",
    "location": {
        "coordinates": [
            50.109230555555555,
            8.757613888888889
        ],
        "type": "Point"
    },
    "name": "Büro",
    "preview": "/img/thumbs/13869-2gqv8n.JPG",
    "type": "image/jpeg",
    "added": "2013-11-11T13:21:10.951Z",
    "latlng": [ ],
    "shares": [ ],
    "shared": false,
    "tags": [ ]
}

获取项目的查询看起来像

{
    // tried also "location.coordinates" without luck
    "location": {
        " $geoWithin": {
            "$box": [
                [
                    49.99825021043669,
                    8.543586730957031
                ],
                [
                    50.139285461134996,
                    8.996772766113281
                ]
            ]
        }
    }
}

结果总是空数组有什么问题?

4

1 回答 1

3

我可以在这里看到一件事是错误的。不" $geoWithin"应该"$geoWithin"吗??

于 2013-11-12T16:23:38.583 回答