这是一个真正的noob问题,但我在文档中找不到明确的答案:
是否可以使用Thinking Sphinx搜索模型对象的关联。
实施例
@user.posts.search("I'm confused")
我看到的所有示例都涉及搜索用户。
答案 0 :(得分:0)
是的,可以搜索模型对象的关联,例如在上传模型关联中创建示例索引。
define_index做 索引标题 索引说明 索引uploads.file_file_name,:as => :upload_file_name index uploads.file_content_type,:as => :upload_file_content_type
has :id
has price
has user_id
has created_at
has purchase_count
has images.photo_file_size
has tags.id, :as => :tag_id, :facet => true
has tags.parent_id, :as => :tag_parent_id, :facet => true
has "state='active'", :as => :active, :type => :boolean, :facet => true
has "count(images.id) > 0", :as => :has_image, :type => :boolean
has "sum(uploads.file_file_size)", :as => :total_size, :type => :integer
端