Rails Geocoder方法将结果限制为100



我正在使用Rails、Mongoid和Geocoder。我的问题是Location.near将返回的结果限制为100,即使对于应该产生超过100的结果也是如此。我需要一种方法来返回任何位置的所有结果。

Location.near([28.4989, -87.7271], 1).count
=> 100

我尝试了几种方法,看起来我应该做类似于下面的方法,它仍然返回100。

Location.near([28.4989, -87.7271]).limit(200).count
=> 100

编辑:这似乎是near方法及其默认限制100的已知问题。我找到了一个返回所有结果的Mongoid查询。

Location.where(:coordinates.within => { "$center" => [ [-87.7271, 28.4989], 0.01] }).count
=> 186

这似乎是near方法及其默认限制100的已知问题。我找到了一个返回所有结果的Mongoid查询。

Location.where(:coordinates.within => { "$center" => [ [-87.7271, 28.4989], 0.01] }).count
=> 186

最新更新