Rails 3.2 と Thinking Sphinx 3 を使用しています。次の関連モデルがあります。
# country.rb
class Country < ActiveRecord::Base
has_many :states
end
# state.rb
class State < ActiveRecord::Base
belongs_to :country
has_many :state_shops
has_many :shops, :through => :state_shops
end
# state_shop.rb
class StateShop < ActiveRecord::Base
belongs_to :state
belongs_to :shop
end
# shop.rb
class Shop < ActiveRecord::Base
end
でcountry.rb
の名前を検索したいshop
。のインデックスは次のcountry
とおりです。
# country_index.rb
ThinkingSphinx::Index.define :country, :with => :active_record do
indexes :name
has budget, duration, overall_rating, created_at
end
を検索するには、関連するインデックスをどのようにすればよいshop.name
ですか?