質問

ThinkingSphinxに自分の状態を認識させることができません。

私のディスカッションモデルには次のコードが含まれています。

define_index do
  indexes [subject, body], :as => :text
  indexes replies.body, :as => :reply_text
  set_property :delta => true
end

そして予想どおりこの検索

Discussion.search "handy"

" handy"という言葉での議論を返します。件名、本文、または返信のいずれかの本文。

今、「投稿の削除」を実装しています。機能、および:disabled == falseというフィールドのディスカッションのみを表示したい。

残念ながら、この検索:

Discussion.search "handy", :conditions => { :disabled => false }

常に、空の配列を返します。

なぜ?

役に立ちましたか?

解決

define_index ブロックで disabled 属性を定義する必要があります:

define_index do
  indexes [subject, body], :as => :text
  indexes replies.body, :as => :reply_text

  has disabled

  set_property :delta => true
end

これを実行したら、Sphinxを停止し、インデックスを再作成して再起動すると、うまくいくはずです。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top