Ruby on Rails思考 - sphinx有很多通过索引

时间:2013-04-05 09:44:48

标签: ruby-on-rails full-text-search thinking-sphinx

干杯!我有tour模型与这些关联:

  has_many :tour_in_the_countries
  has_many :country, :through => :tour_in_the_countries

在tour_index.rb

ThinkingSphinx::Index.define :tour, :with => :active_record do
  indexes :title
  indexes :preview
end

在这种情况下如何添加到索引国家/地区的名称?

1 个答案:

答案 0 :(得分:2)

这应该可以解决问题:

indexes tour_in_the_countries.country.name, :as => :countries