0

这是一个真正的菜鸟问题,但我无法在文档中找到明确的答复:

是否可以使用 Thinking Sphinx 搜索模型对象的关联。

例子:

@user.posts.search("I'm confused")

我看到的所有示例都涉及搜索用户。

4

1 回答 1

0

是的,可以搜索模型对象的关联,例如针对上传模型关联创建索引的示例。

define_index 做索引标题索引描述索引uploads.file_file_name, :as => :upload_file_name 索引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

结尾

于 2013-03-18T22:31:45.793 回答