Solr搜索多个字段,包括字段关联

时间:2016-10-14 03:01:16

标签: ruby-on-rails solr

我有以下课程:

class User < ActiveRecord::Base
    searchable do
       text :full_name, boost: 3.0
       text :about_me
       join(:name, target: Nickname, type: :text, join: { from: :user_id, to: :id })
    end
end

class Nickname < ActiveRecord::Base
    searchable do
        text :name
        integer :user_id
    end
end

我想要做的是通过其full_name,about_me搜索用户,或者在搜索到的电子邮件中添加昵称。

我尝试了以下内容,但我从未得到过结果:

 User.search { fulltext 'FrodoBaggings' }.results
 User.search { fulltext 'FrodoBaggings'; fulltext 'Frodo', fields: [:name] }
 User.search do 
     any do
         fulltext 'Frodo Baggings', fields: [:full_name, :about_me]
         fulltext 'Frodo Baggings', fields: [:name]
     end
 end

0 个答案:

没有答案