Hi, I'm trying to use geo facilities of Sphinx. And am having two
issues with it.
First, regular search (Model.search ...) works smoothly. No problems.
But when I try to make use of geo sorting or geo filtering, I see
these:
1. No way to get distances for each Ad. There is no such function as
@ads.each_with_geodist, which is mentioned in the documentation.
2. If I try to add filtering by @geodist attribute (... :conditions
=> {"@geodist" => -1000000000000000000000.0..20000000000000.0} ...) I
get empty collection as a result.
Details:
Model
class Ad < ActiveRecord::Base
define_index do
indexes title
indexes description
has 'RADIANS(lat)', :as => :lat, :type => :float
has 'RADIANS(lon)', :as => :lon, :type => :float
set_property :latitude_attr => 'lat'
set_property :longitude_attr => 'lon'
end
end
Use
@ads = Ad.search params[:query], :geo => [params
[:lat].to_f*Math::PI/180, params[:lon].to_f*Math::PI/180], \
:per_page => 50, :order => "@geodist ASC"
I've tried to run this code with different version of Sphinx(0.9.8.1,
0.9.9-rc1) and ThinkingSphinx(0.9.5, edge), but still no luck.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---