Ruby on rails 3 思考狮身人面像的对象是如何处理的,属于并有很多联系的?

Ruby on rails 3 思考狮身人面像的对象是如何处理的,属于并有很多联系的?,ruby-on-rails-3,sphinx,thinking-sphinx,Ruby On Rails 3,Sphinx,Thinking Sphinx,我正在使用thinking sphinx(版本2.0.11)进行搜索,但是我遇到了一些问题。假设我有一个名为Product的模型,我正在使用thinking sphinx搜索产品。产品属于公司,公司有很多领域,一个领域也有很多公司。以下是我的一些代码: class Product < ActiveRecord::Base #....skip some code... belongs_to :company belongs_to :area define_index do

我正在使用thinking sphinx(版本2.0.11)进行搜索,但是我遇到了一些问题。假设我有一个名为Product的模型,我正在使用thinking sphinx搜索产品。产品属于公司,公司有很多领域,一个领域也有很多公司。以下是我的一些代码:

class Product < ActiveRecord::Base
  #....skip some code...

  belongs_to :company
  belongs_to :area

  define_index do
    indexes :name
    indexes description
    indexes company(:name)
    indexes company.introduction
    indexes company.areas.area #column of model area
  end
end
类产品
这是我的模型公司和区域

class Company < ActiveRecord::Base
  has_many :products
  has_many :areaships
  has_many :areas, :through => :areaships
end

class Area < ActiveRecord::Base
  has_many :areaships
  has_many :companies, :through => :areaships
  has_many :products, :through => :companies
end
class公司:区域
终止
类区域:区域船舶
有许多:产品,:通过=>:公司
终止
正如你所看到的,一个产品属于一个公司,一个公司拥有并属于许多领域。如何使用thinking sphinx搜索特定产品的区域?假设该地区是巴黎,如果我在巴黎输入密钥,我应该得到属于巴黎的一些公司的所有产品的结果。我已经试了好几天了,但还是想不出来。感谢您的帮助