使用以下配置在相關模型上定義索引的正確方法是什麼?使用Thinking Sphinx定義相關模型的索引
我有lat
和lng
屬性和關聯模型Profile
和User
class User < ActiveRecord::Base
has_one :user_profile
define_index do
# This doesn't work :(
has "RADIANS(user_profiles.localities.lat)", :as => :lat, :type => :float
has "RADIANS(user_profiles.localities.lng)", :as => :lng, :type => :float
end
end
end
class UserProfile < ActiveRecord::Base
belongs_to :user
belongs_to :locality
end
class Locality < ActiveRecord::Base
has_many :user_profiles
end
我需要定義用戶模型,這樣我就可以在其上進行地理搜索索引模型Locality
。
謝謝你的答案!
太棒了,對不起,我已經創造了困惑:) – 2011-02-14 23:59:48