threatagent
threatagent

Reputation: 260

Rails Geocoder near method limiting results to 100

I'm working with Rails, Mongoid, and Geocoder. My issue is Location.near is limiting results returned to 100, even for results that should yield over 100. I need a way to return all the results for any location.

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

I tried several methods and it looks like I should be doing something similar to the following, which still returns 100.

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

Edit: It appears that this is a known issue with the near method and its default limit of 100. I was able to find a Mongoid query that returns all results.

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

Upvotes: 3

Views: 934

Answers (1)

threatagent
threatagent

Reputation: 260

It appears that this is a known issue with the near method and its default limit of 100. I was able to find a Mongoid query that returns all results.

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

Upvotes: 2

Related Questions