I have this working query (correctly finds the 2 cities within 10 miles of the center):
db.customers.find({ "location" : { $within : { $center : [[-117.15,32.72],0.15] }
Attempted complement query (desired result is the 1 city that is not within 10 miles):
db.customers.find({ "location" : { $not : { $within : { $center : [[-117.15,32.72],0.15] } } } })
error: {
"$err" : "missing geo field (location) in : {location: { $not: { $within: { $center: [ [ -117.15, 32.72 ], 0.15 ] } } } }",
"code" : 13042
}
For anyone that wants to copy/paste the query to see the error, here's a tiny bit of sample data:
db.customers.ensureIndex( { "location" : "2d" } )
db.customers.save({"city":"La Mesa","state":"CA","location":[ -117.02,32.76 ]})
db.customers.save({"city":"Chula Vista","state":"CA","location":[ -117.08,32.63 ]})
db.customers.save({"city":"Mexico City","state":"Mexico","location":[-99.133244,19.4326]})
(I'm using MongoDB 1.8.2 in case that matters.)
If this is threadjacking, just let me know. But it seems like it might be the same issue.