2

I'm trying to query my collection using geoSpatial query to return results near to a point, along with the distance from that point.

I'm using Queryable#near_sphere with Mongoid http://mongoid.org/en/origin/docs/selection.html This executes the $nearSphere command on the query.

I've seen the geoNear command: http://www.mongodb.org/display/DOCS/Geospatial+Indexing#GeospatialIndexing-geoNearCommand

This seems to return the results, with the calculated distance

Is there a way to either:

a) return the distance using nearSphere
b) use geoNear with Mongoid

Alex
  • 37,502
  • 51
  • 204
  • 332

1 Answers1

0

I dont think this command is available on Origin, you might open a feature request if you wish https://github.com/mongoid/origin/issues.

As a work around you can issue the command straight from moped, something like this:

Person.mongo_session.command({ :geoNear => 'places' })...

than you can put together your command, following the docs from mongodb.

Arthur Neves
  • 11,840
  • 8
  • 60
  • 73