使用mongomapper执行服务器runCommand geoNear

发布于 2024-12-20 09:22:30 字数 752 浏览 1 评论 0原文

我非常想使用 此处讨论的 mongo geoNear 命令。

这是我在 Rails 控制台中输入的命令以及附带的错误消息。

MongoMapper.database.command({ 'geoNear' => "trips", 'near' => [45,45]})
Mongo::OperationFailure: Database command 'geoNear' failed: 
  (errmsg: 'more than 1 geo indexes :('; ok: '0.0').

我无法理解该错误消息,据说不可能有超过 1 个地理索引,而且我确信我只创建了一个。

基于这个stackoverflow问题 我相信我对查询的措辞是正确的。有人理解该错误消息吗?我将如何销毁并重新创建索引?

我正在使用 Rails 3.1 和 mongodb v2.0 以及 mongo ruby​​ gem v1.5.1。

I would very much like to use the mongo geoNear command as discussed here.

Here is the command I entered in my rails console with the accompanying error message.

MongoMapper.database.command({ 'geoNear' => "trips", 'near' => [45,45]})
Mongo::OperationFailure: Database command 'geoNear' failed: 
  (errmsg: 'more than 1 geo indexes :('; ok: '0.0').

I can not make sense of the error message, it is supposedly impossible to have more than 1 geo index and I am certain that I have only created one.

Based on this stackoverflow question I believe I am wording the query correctly. Does anyone understand that error message? How would I go about destroying and recreating my indexes?

I am using rails 3.1 with mongodb v2.0 and the mongo ruby gem v1.5.1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

信仰 2024-12-27 09:22:30

我真的问得太早了,也许我应该删除它?不知何故,实际上地理索引太多了,因为删除索引并重新创建它可以解决问题。

MongoMapper.database.collection('trips').drop_indexes
Trip.ensure_index [[:route, '2d']]

I really asked this too soon, maybe I should delete it? Somehow there were in fact too many geo indexes, because deleting the index and recreating it fixed the problem.

MongoMapper.database.collection('trips').drop_indexes
Trip.ensure_index [[:route, '2d']]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文