2

我正在尝试使用 geoSpatial 查询来查询我的集合,以返回靠近某个点的结果以及与该点的距离。

我正在使用Queryable#near_sphereMongoid http://mongoid.org/en/origin/docs/selection.html 这将在查询中执行 $nearSphere 命令。

我看过geoNear命令: http ://www.mongodb.org/display/DOCS/Geospatial+Indexing#GeospatialIndexing-geoNearCommand

这似乎返回了计算距离的结果

有没有办法:

a) 使用 nearSphere 返回距离
b) 将 geoNear 与 Mongoid 一起使用

4

1 回答 1

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.

于 2013-01-24T22:52:02.047 回答