使用sunspot/solr搜索多个模型

ozi*_*ind 5 search solr model sunspot

我已经能够成功地实现基本的全文搜索,但是当我尝试使用范围("with statements")时,任何涉及多对多关系模型的查询似乎都不适合我.我知道相关的行在db中,因为我的sql语句确实返回了数据.然而,太阳黑子的查询并没有返回任何结果......我确定它可能是我新手上的新手......任何帮助都会非常感激......所以我们走了.......

我的模特

class User
    has_one :registration

    searchable do
        text  :first_name
        text  :last_name
        text  :email
    end
end

class Registration
    belongs_to    :user
    has_many    :registration_programs
    has_many    :programs, :through => :registration_programs     

    searchable do
        integer :user_id
        integer :registration_status_id
    end
end

class RegistrationProgram
    belongs_to :registration
    belongs     :program

    searchable do
        integer :registration_id
        integer :program_id
    end     
end
Run Code Online (Sandbox Code Playgroud)

我在控制器中的查询

    @search = Sunspot.search(User, Registration, RegistrationPrograms)do

    # this works fine with the frame, lame, email fields "on its own"
    fulltext params["instructor-search"]

    any_of 
        all_of 
            with(:class => Registraion)
            with(:registration_status_id, 3)                             
        end

        all_of 
            with(:class => RegistraionProgram)
            with(:program_id, 1) 
        end
    end
end
Run Code Online (Sandbox Code Playgroud)

数据库中有一些记录,其foo为f_name,其reg状态和程序字段为3和1个ID.但是我无法让Sunspot/websolr得到它们......我唯一一次让上述查询工作就是当我单独运行所有三个标准时.......每当我组合它们时,我似乎没有返回任何行.

任何帮助/建议将不胜感激.......