I'm having trouble running this query against a field indexed as 2dspherical using mongodb 2.4rc3
db.contact2.find({geo_2: { $within:
{ $geometry: { "type": "Polygon",
"coordinates": [[
[-88.352051,30.977609],
[-81.320801,30.694612],
[-79.431152,25.383735],
[-81.013184,24.487149],
[-82.990723,27.741885],
[-83.540039,29.401320],
[-88.308105,30.126124]
]]
}
}
} });
I have tried using both $within and $geoIntersects (not sure that one is what I want) and both of these give me a parsing error
error: {
"$err" : "can't parse query (2dsphere): { $within: { $geometry: { type: \"Polygon\", coordinates: [ [ [ -88.352051, 30.977609 ], [ -81.320801, 30.694612 ], [ -79.431152, 25.383735 ], [ -81.013184, 24.487149 ], [ -82.990723, 27.741885 ], [ -83.54003899999999, 29.40132 ], [ -88.308105, 30.126124 ] ] ] } } }",
"code" : 16535
}
I used
http://geojsonlint.com/ to validate the Polygon JSON and it says it's correct so I don't know why the query is rejected. I can successfully do similar queries against 2d indexes using $within+$polygon but I was hoping for better count performance with the 2dspherical index.