Sunspot geo spatial search setup question

43 views
Skip to first unread message

Cristiano

unread,
Feb 26, 2011, 7:09:33 PM2/26/11
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.
Reply all
Reply to author
Forward
0 new messages