0

これは本当の初心者の質問ですが、ドキュメントで明確な回答を見つけるのに苦労しています:

Thinking Sphinx を使用してモデル オブジェクトの関連付けを検索することは可能ですか。

例:

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

私が見るすべての例は、ユーザーの検索を伴います。

4

1 に答える 1

0

はい、アップロードされたモデルの関連付けに対してインデックスが作成される例のように、モデル オブジェクトの関連付けを検索することができます。

define_index do インデックス タイトル インデックス 説明 インデックス 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 に答える