Hi Steven, I had a similar problem. Try adding the following to your query: :latitude_attr => :latitude, :longitude_attr => :longitude
These tell Thinking Sphinx which attributes to use for geodist, since you have both lat and latitude. -T- On Wed, Dec 14, 2011 at 20:49, Steven Bristol <[email protected]> wrote: > Using ts 1.3.16 on a rails 2.3.8 app: > > > > Here is the index: > > > define_index do > indexes name, :sortable=>:true > indexes zip > has zip_code.lat #need this or ts won't add the join for the > zip_codes table. hopefully this will be fixed in a new version of ts > has "RADIANS(zip_codes.lat)", :as => :latitude, :type => :float > has "RADIANS(zip_codes.lng)", :as => :longitude, :type => :float > set_property :delta => :datetime, :threshold => 10.minutes > set_property :enable_star => true > set_property :morphology => 'none' > end > > > > > Here is the truncated data from the sphinx query: > > id name zip lat latitude longitude > 3 steve 32257 30.1893550000 0.526903643803413 > -1.42440622491863 > 4 allan 91711 34.1274400000 0.595636193276814 > -2.0545192857202 > > > > Here is the ts query: > > Model.search :per_page=>25, :enable_star=>true, :geo=>[0.5956361925962, > -2.05451928337257], :min_prefix_len=>0, :order=>"@geodist ASC, > @relevance DESC", :page=>1, :min_infix_len=>1 > > > Here are the results: > > [#<Model id: 3, name: "steve">, #<Model id: 4, name: "allan">] > > > Here is the geodist: > > results.map{|x| x.sphinx_attributes['@geodist']} > [11989305.0, 13507781.0] > > > > Am I crazy? > 1. Shouldn't the results be in order [4,3]? > 2. Shouldn't the map of geodist be more like [close to zero, really > big number]? > > -- > 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. > -- 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.
