Hi Zoran

Only thing I can offer is that if you get a city match, take that  
city's name out of the Tip search, since the geographic position  
should cover that.

ie:
@results = Tip.search(
   params[:user_input].gsub(/#{geo_city.name}/i, ''),
   :geo        => [city_lat, city_long],
   :conditions => {:theme_name => params[:theme]},
   :with       => {"@geodist"  => Range.new(0.0, radius)},
   :order      => "@weight, @geodist ASC",
   :per_page   => 50
)

This is all search semantics though - perhaps it's worth asking on the  
Sphinx forums?

-- 
Pat

On 20/10/2008, at 12:06 PM, zoran wrote:

>
> Hard to explain.. :) The search terms are user-entered - look at my
> screen shot: http://zoran.name/ty_form.png
>
> Assume
>  - hamburg has 100 hotels
>  - berlin has 1 hotel
>  - distance between cities: 289 km
>  - range for geodist: 280 km
>
> A user search for "Berlin" by clicking on the "Hotel" button. He will
> get only the 1 hotel in Berlin and probably hotels in Hamburg which
> have "Berlin" in their names. That's right but I want to show him
> other hotels in range as well because he clicked on "Hotel".
>
> I should mention that I first check the user input for city names. If
> the search string contains a city name, it will be used for geodist.
>
> Something like this:
>
> geo_city = City.search params[:user_input]
> if geo_city.size == 1 && !geo_city[0].id.to_s.blank? && !
> geo_city[0].lat.to_s.blank? && !geo_city[0].lng.to_s.blank?
>    city_lat = (geo_city[0].lat / 360.0) * Math::PI * 2
>    city_long = (geo_city[0].lng / 360.0) * Math::PI * 2
>    city_radius = geo_city[0].radius.to_f * 1000.0
>
>    @results = Tip.search params[:user_input], :conditions =>
> {:theme_name => params[:theme]},
>        :geo => [city_lat, city_long],
>        :with => {'@geodist' => Range.new(0.0, radius)},
>        :order => "@weight, @geodist ASC",
>        :per_page => 50
> end
>
>
> Cheers
>
> Zoran
>
> >


--~--~---------~--~----~------------~-------~--~----~
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