ThinkingSphinx는 조건을 수용하지 않습니다
-
03-07-2019 - |
문제
내 조건을 인식하기 위해 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 }
무엇이든 항상 빈 배열을 반환합니다.
왜요?
해결책
속성이 필요합니다 disabled
당신의 정의 define_index
차단하다:
define_index do
indexes [subject, body], :as => :text
indexes replies.body, :as => :reply_text
has disabled
set_property :delta => true
end
이 작업을 마치면 Sphinx, Reindex 및 다시 시작하면 작동하기를 바랍니다.
제휴하지 않습니다 StackOverflow