我想使用 geo_near 在我的应用程序中进行环视功能我已经在我的模型上创建了索引
...
field :location, Type: Array
index({ location: "2d" })
self.create_indexes
我已经跑了
rake db:mongoid:create_indexes
这是我在控制器中使用的代码
@merchants = Merchant.geo_near([coordinate.first.to_f, coordinate.last.to_f]).max_distance(50)
但我得到错误说:
Mongo::Error::OperationFailure(没有这样的命令:'geoNear' (59)(在 localhost:27017 上)(在 localhost:27017 上)):
我使用 mongoid 7、ruby on rails 6.0.2、ruby 2.6.3、mongo 4.2.2
您可以在此处查看完整的日志跟踪trace_log.txt