I've a problem with a query matching items inside a BoundingBox.
I've read in the mongo documentation a lot without success about $box and $geoWithin but can't figure out why the item which is inside the queried box is not resulting.
Here an example from defined Schema over an Item inside and the Query to get it out
The schemadefinition looks like this and it's validation is working.
/**
* Media location values (Point, LineString, Polygon)
* @property location
* @type {Object}
*/
location:{
"type":Object,
"index":"2dsphere"
},
One item inside looks like this (which is expected as a result of the query):
{
"_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": [ ]
}
The query to fetch the item looks like
{
// tried also "location.coordinates" without luck
"location": {
" $geoWithin": {
"$box": [
[
49.99825021043669,
8.543586730957031
],
[
50.139285461134996,
8.996772766113281
]
]
}
}
}
Whats wrong here to get always en empty array as result?
I can see one thing that is wrong here. Shouldnt " $geoWithin" be "$geoWithin" ??
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With