私はこれを簡単に持っていると思っていました..しかし、キーワードでクエリを実行するたびに、SQLからテーブルをロードしません。エラーは発生しません。
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
まったく検索しないと、すべてのUser
結果が正常に表示されます
これらすべての文字列タグをテキストタグにすると思いますが、次のエラーが返されます。
Sunspot::UnrecognizedFieldError in Admin/usersController#index
No field configured for User with name 'first_name'
これをキーワードに応答させるには何が欠けていますか?