The problem is twofold:
- Thinking Sphinx does not know that you want to join the user_profile and locality associations.
- SQL fragments should be like standard SQL, so you cannot bind associations within them.
The following should do the trick:
define_index do
join user_profile.locality
has "RADIANS(localities.lat)", :as => :lat, :type => :float
has "RADIANS(localities.lng)", :as => :lng, :type => :float
end
Claudio SQL - SQL , . (, ).