Bingo! Thanks!! Works beautifully. Thanks for the awesome job!
On May 31, 6:06 pm, Pat Allan <[email protected]> wrote: > Almost, but not quite... you need the options in your search call, not in > your index properties: > > ThinkingSphinx.search( > :geo => ll, > :with => {"@geodist" => 0.00..(20 * 1609.344)}, > :latitude_attr => :latitude, > :longitude_attr => :longitude > ) > > -- > Pat > > On 01/06/2010, at 11:01 AM, badnaam wrote: > > > So I did this.. > > > define_index do > > indexes user.username, :as => :author > > indexes subject, :as => :subject > > indexes content, :as => :content > > > has created_at, updated_at > > has user(:id), :as => :author > > > has 'RADIANS(lat)', :as => :latitude, :type => :float > > has 'RADIANS(lng)',:as => :longitude, :type => :float > > set_property :latitude_attr => :latitude > > set_property :longitude_attr => :longitude > > end > > > Same for my Store model. > > define_index do > > indexes :name, :sortable => true > > indexes :description, :as => :description > > indexes :city, :as => :city > > indexes :state, :as => :state > > indexes :country, :as => :country > > > has created_at, updated_at, city, name > > > has 'RADIANS(lat)', :as => :latitude, :type => :float > > has 'RADIANS(lng)',:as => :longitude, :type => :float > > > set_property :latitude_attr => :latitude > > set_property :longitude_attr => :longitude > > end > > > Still doesn't return anything. > > > On May 31, 5:46 pm, Pat Allan <[email protected]> wrote: > >> This is because, with more than one model, TS doesn't have a reference > >> point for attributes, and so doesn't try to guess what your lat/lon > >> attributes are. If you explicitly add :latitude_attr => :latitude, > >> :longitude_attr => :longitude to your ThinkingSphinx.search call, that > >> should make it work. > > >> Cheers > > >> -- > >> Pat > > >> On 01/06/2010, at 10:41 AM, badnaam wrote: > > >>> OK, my get_radian method was the problem, I was sending it the wrong > >>> parameters. > >>> instead of .. > > >>> l = (Geokit::Geocoders::GoogleGeocoder.geocode 'xxxxx').ll > >>> la = Address.get_radian(l[0], l[1]) > > >>> it should be > >>> l = (Geokit::Geocoders::GoogleGeocoder.geocode 'xxxxx') > >>> la = Address.get_radian(l.lat, l.lng) > > >>> My apologies for the silly mistake! > > >>> So now it works. But I have another problem. > > >>> I am using geo search on two models Store and Article > > >>> When I do this.. > > >>> Article.search(:geo => ll, :with => {"@geodist" => 0.00..(20 * > >>> 1609.344)})..it works > >>> Store.search(:geo => ll, :with => {"@geodist" => 0.00..(20 * > >>> 1609.344)})..it works > >>> ThinkingSphinx.search ("lorem") works too. > >>> ThinkingSphinx.search(:geo => ll, :with => {"@geodist" => 0.00..(20 * > >>> 1609.344)}, :classes => [Article]) or ThinkingSphinx.search(:geo => > >>> ll, :with => {"@geodist" => 0.00..(20 * 1609.344)}. :classes => > >>> [Store])...works too! > > >>> But. > >>> ThinkingSphinx.search(:geo => ll, :with => {"@geodist" => 0.00..(20 * > >>> 1609.344)}) or ThinkingSphinx.search(:geo => ll, :with => {"@geodist" > >>> => 0.00..(20 * 1609.344)}. :classes => [Store, Article])..does not > >>> work. > > >>> Any reason? > > >>> Thanks > > >>> On May 31, 9:42 am, badnaam <[email protected]> wrote: > >>>> Could this be happening because lat and lng is stored in a polymorphic > >>>> association? Perhaps the address pluralization issue is causing > >>>> problems internally? Strange thing is that without the @geodist option > >>>> it does product results. Is there a log somewhere that can shed more > >>>> light? > > >>>> Thanks! > > >>>> On May 31, 12:47 am, badnaam <[email protected]> wrote: > > >>>>> I tried that still no result. strange. > > >>>>> On May 30, 11:33 pm, Pat Allan <[email protected]> wrote: > > >>>>>> I'm not sure if it matters, but try changing your set_property values > >>>>>> to symbols instead of strings. Although really, you shouldn't need > >>>>>> them, since you're using standard attribute names. > > >>>>>> Have you restarted Sphinx (and reindexed) since adding the lat/lng > >>>>>> attributes? > > >>>>>> -- > >>>>>> Pat > > >>>>>> On 31/05/2010, at 4:30 PM, badnaam wrote: > > >>>>>>> define_index do > >>>>>>> indexes :name, :sortable => true > > >>>>>>> indexes address.city, :as => :city > > >>>>>>> has created_at, updated_at > > >>>>>>> has 'RADIANS(addresses.lat)', :as > >>>>>>> => :latitude, :type => :float > >>>>>>> has 'RADIANS(addresses.lng)',:as => :longitude, :type > >>>>>>> => :float > > >>>>>>> set_property :latitude_attr => "latitude" > >>>>>>> set_property :longitude_attr => "longitude" > > >>>>>>> end > > >>>>>>> On May 30, 5:38 pm, Pat Allan <[email protected]> wrote: > >>>>>>>> What does your define_index block look like in your Store model? > > >>>>>>>> -- > >>>>>>>> Pat > > >>>>>>>> On 31/05/2010, at 6:53 AM, badnaam wrote: > > >>>>>>>>> I am trying to do a proximity search like.. > > >>>>>>>>> l = (Geokit::Geocoders::GoogleGeocoder.geocode 'xxxxx').ll > > >>>>>>>>> la = Address.get_radian(l[0], l[1]) > > >>>>>>>>> def self.get_radian(lat, lng) > >>>>>>>>> return [(lat / 180.0) * Math::PI, (lng / 180.0) * Math::PI] > >>>>>>>>> end > > >>>>>>>>> Store.search("green", :geo => la, :with => {"@geodist" => > >>>>>>>>> 0.0..50_000.0}) > > >>>>>>>>> This returns no results, I know it should return some records, and > >>>>>>>>> it > >>>>>>>>> does if I take the @geodist out, what am I doing wrong here? > > >>>>>>>>> Thanks > > >>>>>>>>> -- > >>>>>>>>> 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 > >>>>>>>>> athttp://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 > >>>>>>> athttp://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 > >>> athttp://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 > > athttp://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.
