Cristiano
unread,Feb 26, 2011, 7:09:33 PM2/26/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Sunspot
So I have been trying to setup geo search in my rails 3 app using
Sunspot and I am getting stuck. I have the next code in my user:
searchable do
text :name
location :coordinates
end
I (for now) define the location statically:
def coordinates
Sunspot::Util::Coordinates.new(40, 40)
end
And then I have the following search function:
def self.fetch_near(keyword, lat, long, precision)
Sunspot.search(User) do
keywords keyword
with(:coordinates).near(lat, long, :precision =>
precision, :boost => 3)
end
end
I have one user in my database with my name. My problem is that when I
run:
User.search('Cristiano', 40, 40, 7).total
It returns 0. Where if I remove the with().near() condition it returns
1.