Hi Guys,

I am new to this group and to the Thinking Sphinx rails plugin and
Sphinx search dameon. I am up and running and with Thinking Sphinx in
my application and it's truly amazing!  So here is my question, my
application has many tables that store latitude and longitude
information about each item and will return items based on a radius
search, i.e., items that are with x miles between lat and long
points.  Currently I am doing this both in the models and controllers
(messy, but works) using find_by_sql calls and using sql such as this,
for example this controller call for all banners within 10 miles of a
set of lat and longs.

@rsbanners = Banner.find_by_sql ["SELECT * FROM banners
     WHERE (3958*3.1415926*sqrt((bannerlatitude-'#[email protected]}')*
(bannerlatitude-'#[email protected]}')
     + cos(bannerlatitude/57.29578)*cos('#[email protected]}'/57.29578)*
(bannerlongitude-'#[email protected]}')*(bannerlongitude-'#
{[email protected]}'))/180)
     <= 10 AND banneractive = '1'"]

I was able to build my index with lats and longs from the example
documentation and do a basic search against the index for all banners
and sorting by distance.  The geo functionality is fantastic and works
great:
@banners = Banners.search @terms, :geo => [[email protected],
@zip.longitude],:order => "@geodist DESC

Can anyone give me some advice on how to go about converting my
example find_by_sql statement above to using the Thinking Sphinx
plugin?  Can it be done?

Many thanks for your help!  And a huge thanks to Pat Allen for
creating such a fantastic search platform to work with!

--Travis

--

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.


Reply via email to