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