Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 22nd, 2012  |  syntax: None  |  size: 0.68 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. MongoDB geospatial query with $not
  2. db.customers.find({ "location" : { $within : { $center : [[-117.15,32.72],0.15] } } })
  3.        
  4. db.customers.find({ "location" : { $not : { $within : { $center : [[-117.15,32.72],0.15] } } } })
  5. error: {
  6.     "$err" : "missing geo field (location) in : {location: { $not: { $within: { $center: [ [ -117.15, 32.72 ], 0.15 ] } } } }",
  7.     "code" : 13042
  8. }
  9.        
  10. db.customers.ensureIndex( { "location" : "2d" } )
  11. db.customers.save({"city":"La Mesa","state":"CA","location":[ -117.02,32.76 ]})
  12. db.customers.save({"city":"Chula Vista","state":"CA","location":[ -117.08,32.63 ]})
  13. db.customers.save({"city":"Mexico City","state":"Mexico","location":[-99.133244,19.4326]})