how can I search for all geopoints inside an area in mongodb.
My collection has
{
"_id": {
"$oid": "5fa2a64d267b8309fe781d98"
},
"location": {
"coordinates": ["115.880453987155", "-31.925513609342207"]
}
}
And I want to now search this data to see if a user is inside
top: -31.97127, 115.98367 Bottom: -32.11739, 115.85955
I have tried to run
[
{
'$search': {
'location': {
'$geoWithin': {
'$geometry': {
'type': 'Polygon',
'coordinates': [
[
115.8455154208042, -31.97458396927722
], [
115.8830653531429, -31.97460201459856
], [
115.8823782261087, -31.94124526669114
], [
115.8498438592383, -31.9409449398814
], [
115.8455154208042, -31.97458396927722
]
],
'crs': {
'type': 'name',
'properties': {
'name': 'urn:x-mongodb:crs:strictwinding:EPSG:4326'
}
}
}
}
}
}
}
]
But get error Remote error from mongot :: caused by :: Query should contain either operator or collector
