0
我有一個belongs_to帳戶的課程模型。如何編寫輪胎查詢其中的association_id爲零或特定值?
公共課程沒有account_id。
私人課程在account_id中有價值。
如何爲公共和私人課程中的某個搜索字詞進行課程搜索?
LessonContentBlock.search(
:load => true,
:page => (params[:page] || 1)
) do
query do
boolean do
should { string q }
filter :missing => { :field => 'account_id' }
should { string "account_id:#{a.id}" }
end
end
end
我也試過這樣:
LessonContentBlock.search(
:load => true,
:page => (params[:page] || 1)
) do
query { string q }
filter :missing, :field => 'account_id'
filter :term, :account_id => a.id
end
您的代碼引用了變量'a',該變量似乎是您要過濾的特定*帳戶。這是否意味着您試圖查找屬於這個單個私人帳戶「a」或公開的記錄? – 2013-05-04 22:37:14