Re: [ts] @geodist ordering not working properly

92 views
Skip to first unread message

Pat Allan

unread,
Jul 23, 2012, 3:32:19 PM7/23/12
to thinkin...@googlegroups.com
Hi Jason

Simple things first: Are your city lat/lng values stored in degrees, or radians? I'm guessing the former (from a database consistency perspective), so you will need to convert them when passing them into a search.

If I've guessed wrong, let me know and I'll keep pondering.

Cheers

--
Pat

On 23/07/2012, at 8:24 PM, Jason Gilmore wrote:

> I am getting an odd result set returned from TS searching. Here is my index definition:
> <pre><code>
> # Thinking Sphinx #############################################
> define_index do
> indexes :name
> indexes :description
> indexes tags.name, :as => :tag_name
> indexes city.name, :as => :city_name
>
> has "RADIANS(locations.latitude)", :as => :latitude, :type => :float
> has "RADIANS(locations.longitude)", :as => :longitude, :type => :float
>
> set_property :latitude_attr => :latitude, :longitude_attr => :longitude
>
> end
>
> ###############################################################
> </code></pre>
>
> I run searches based on distance from a lat/lon pair that is determined by current location or center of city lat/lon. The basic search is as follows:
>
> <pre><code>
> c = City.find_by_name("New York City")
> Location.search(:geo => [c.latitude, c.longitude], :order => "@geodist ASC")
> </code></pre>
>
> This should find the 20 closest locations to the center of New York City, but instead it finds 20 locations in Austin, Texas. If I instead search for the closest locations to the center of Austin, TX I get locations in San Diego, CA. San Diego returns Seattle, WA. Seattle returns Miami, FL. I have verified the lat/lon pair of each of these cities and the location lat/lon is automatically generated by a call to google maps.
>
> In addition, the results are in order of distance from the supplied lat/lon, they just aren't the closest by far.
>
> Is there some other config I'm missing? Did I do something wrong? Any help is much appreciated.
>
> Jason Gilmore
> developer - www.the42.com
>
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/CUVdiKdZ89QJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.



Jason Gilmore

unread,
Aug 4, 2012, 8:34:43 PM8/4/12
to thinkin...@googlegroups.com
Sorry for such a late reply, but I was able to get it sorted out. It was indeed a mismatch between degrees and radians. Thank you for the help and a great gem.

> To post to this group, send email to thinking-sphinx@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphinx+unsubscribe@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages