我以爲我有這個蛋糕......但任何時候我對任何關鍵字進行查詢,它不會從SQL加載任何表。我沒有得到任何錯誤。這個Solr-Sunspot設置的哪部分我缺少?
user.rb
searchable do
string :first_name
string :last_name
string :name
string :email
time :created_at
end
users_controller.rb
class Admin::UsersController < Admin::ApplicationController
def index
s = Sunspot.search User do |query|
query.keywords params[:q]
query.any_of do |any_of|
any_of.with(:first_name)
any_of.with(:first_name)
any_of.with(:email)
any_of.with(:name)
end
query.paginate :page => (params[:page] && params[:page].to_i || 1), :per_page => 20
query.order_by('created_at', 'desc')
end
s.execute!
@users = s.results
render :action => 'index'
end
然後我跑:
$> script/console
$> User.reindex
當我做在all..it成功沒有搜索顯示全部User
結果
我相信我做所有這些字符串變量轉換爲文本標籤,但返回此錯誤:
Sunspot::UnrecognizedFieldError in Admin/usersController#index
No field configured for User with name 'first_name'
缺少什麼我得到這個關鍵字應對?