Start a new topic

Problem with compound query including $nearSphere

Hi there --

I can get this to return correctly --


however, once I compound other queries (like so):


I get this error from the API console:

"can't find any special indices: 2d (needs index), 2dsphere (needs index), for: { $and: [ { _geoloc: { $nearSphere: [ -80.09382273759985, 40.61802747989707 ], $maxDistance: 200 } }, { hideAge: { $ne: false } } ] }"

I seem to be able to compound any queries I'd like until I add a $nearSphere request and I'm at a bit of a loss -- any idea what could be going on/how to get it working?

Hi Calvin,

You've run into a known bug with MongoDB, our underlying database, which does not allow you to use the $and operator in combination with a geospatial query. However, you can perform an implicit AND operation by simply combining the objects in the array:

(the underscore before geoloc was stripped from my answer)
Login or Signup to post a comment