- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试在 MongoMapper 支持的模型中封装一个具有 maxDistance 的近查询。
我一定是在我的查询语法中做了一些愚蠢的事情。
模型
class Site
include MongoMapper::Document
key :id, Integer
key :name, String
key :location, Array
ensure_index [[:location, '2d']]
def self.nearest(center_point, range)
where(:location => {'$near' => center_point, '$maxDistance' => range}).all
end
end
试图让所有东西都在一个点的 200 英里范围内......
Site.nearest([-122.0,44.0],200)
> Mongo::OperationFailure: geo values have to be numbers: {
> $maxDistance: 200, $near: [ -122.0, 44.0 ] } from
> /Library/Ruby/Gems/1.8/gems/mongo-1.6.1/lib/mongo/cursor.rb:144:in
> `next' from
> /Library/Ruby/Gems/1.8/gems/mongo-1.6.1/lib/mongo/cursor.rb:290:in
> `each' from
> /Library/Ruby/Gems/1.8/gems/mongo-1.6.1/lib/mongo/cursor.rb:308:in
> `to_a' from
> /Library/Ruby/Gems/1.8/gems/mongo-1.6.1/lib/mongo/cursor.rb:308:in
> `to_a' from
> /Library/Ruby/Gems/1.8/gems/plucky-0.4.4/lib/plucky/query.rb:74:in
> `all' from /Users/nick/Code/web/map/app/models/site.rb:40:in
> `nearest' from (irb):
最佳答案
您可能遇到了 this bug这需要 $near
和 $maxDistance
与 $maxDistance
一起排序。
无论如何,我发现这个问题是因为我在使用 PyMongo 时遇到了OperationFailure: database error: geo values have to be number
,交换顺序修复了它。
关于mongodb - MongoMapper 接近 maxDistance - Mongo::OperationFailure:地理值必须是数字:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10020755/
我正在使用 mongoid 3.1.4 以及 moped 1.5.1、mongodb 2.4.1 和 ruby 1.9.3。 我有下一个模型: class Practice include M
我在不同的 port 上使用不同的 dbpath 启动了 3 个 mongod 进程。 ./bin/mongod --replSet foo/tauquir:27018,tauquir:27019 -
我正在尝试在 Django 中使用 MongoDB 数据库。为此,我将我的设置更改为此,我在这里使用 mlab。 settings.py DATABASES = { 'default': {
我在写入 MongoDB 时在 python 中遇到 pymongo OperationsFailure。除了回溯之外,是否有办法打印出详细信息或代码属性? 另见:http://api.mongodb
我的目标是连接我的 heroku/mongolab 数据库,但我一直收到此错误: Mongo::OperationFailure at /mongotest/a/b : need to login f
我收到如下错误:追溯(最近一次通话最后一次): pymongo.errors.OperationFailure: command SON([('mapreduce', u'tweets'), ('ma
我有一个聚合查询,如下所示: pipeline = [ {"$match": {"col_name": "value"}}, {"$group": {"
我正在使用 ruby/grape 和 mongoid 创建一个应用程序。但是当我尝试使用 mongoid 在任何集合中创建或查找文档时,例如使用 Admin.create 我收到以下错误: ERR
我正在尝试在 MongoMapper 支持的模型中封装一个具有 maxDistance 的近查询。 我一定是在我的查询语法中做了一些愚蠢的事情。 模型 class Site include Mon
我正在创建一个集合并希望将其插入到我的数据库中 我已经导入了 pymongo 并且我也这样定义了 db = myClient["mydb"] 但它说命令插入需要身份验证 >>> import pym
我们在进行查询时偶尔会遇到以下错误: OperationFailure: database error: error querying server 没有导致此问题的特定查询,并且在重复该过程时一切正
我在使用 MongoHQ Heroku 插件时遇到问题。我的应用程序在本地工作,并且 os 变量在 Heroku 上存在且格式正确。但是,当我尝试访问数据库时,它会引发错误:OperationFail
我一直遇到一个问题,在我通过 pymongo 连接到 mongohq 的 mongodb 连接空闲一段时间(没有查询)后,它会超时。这很好,但数据库连接仅在 Django 应用程序启动时创建。看起来它
我正在使用 django-nonrel 和 mongodb-engine 运行 python manage.py syncdb 时出现以下错误: Traceback (most recent call
我最近使用 rails 3.2.12 和 ruby 1.9.3 从 mongoid 2.0.2 升级到 mongoid 3。 Following issue comes when save com
我有一个应用程序可以通过 Padrino 中的 MongoMapper/Joint 将文件上传到 GridFS。一切正常,然后突然出现错误: Mongo::OperationFailure at /a
使用 Rails 3,从 Mongoid 2.x 升级到 Mongoid 3.x 后,我的 Heroku + MongoHQ 设置停止工作。有趣的是,我的开发和测试框架以及我的整个测试套件都通过了。
我在运行 cucumber 测试时遇到这个奇怪的错误: ERROR Mongo::OperationFailure: Database command 'filemd5' failed: {"errm
最近,我们将 CI 上的 mongodb 设置为 ReplicaSet。我们有两个节点 localhost:27017、localhost:27018 和 localhost:27019 上的仲裁器(
我是一名优秀的程序员,十分优秀!