我无法索引我的数据库以使用 sunspot_rails 进行搜索。我收到以下错误:
执行 sunspot:reindex rake 中止!未定义的局部变量或方法“计数器”
运行 rake sunspot:reindex 后,我得到以下输出。我是 Rails 的新手。我想将 sunspot_rails 添加到我的项目中以添加搜索功能(希望使用 Heroku 部署项目)。
我正在使用 Rails 3。我按照此处的说明进行操作:https ://github.com/outoftime/sunspot/blob/master/sunspot_rails/README.rdoc 。我诊断问题的各种其他尝试包括:
- 除了 sunspot_rails 之外还安装 sunspot。
- 我最终得到了 sunspot_rails v. 1.2.0 和 1.2.1,所以我卸载了 1.2.1,因为我有 sunspot_rails 1.2.0。
- 安装了我理解的 nokogiri gem 是 sunspot_rails 的依赖项。
按照此处安装 nokogiri 的说明单独安装 libxml2:http ://www.engineyard.com/blog/2010/getting-started-with-nokogiri/
** 调用 sunspot:reindex (first_time) ** 调用环境 (first_time) ** 执行环境 ** 执行 sunspot:reindex rake 中止!未定义的局部变量或方法
counter' for [removed pound]<Class:0x10359aef8> /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:1008:in
method_missing' /Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/rails/searchable.rb:235:insolr_index' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/relation/batches.rb:71:in
find_in_batches' /Library/Ruby/Gems/1.8/gems/ activerecord-3.0.3/lib/active_record/base.rb:440:in__send__' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:440:in
find_in_batches'/ Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/rails/searchable.rb:234:insolr_index' /Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/rails/searchable.rb:184:in
solr_reindex ' /Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/rails/tasks.rb:57 /Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/ rails/tasks.rb:56:ineach' /Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/rails/tasks.rb:56 /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
call' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
每个' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby /1.8/monitor.rb:242:insynchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
invoke_task' /Library/Ruby/Gems/1.8/gems /rake-0.8.7/lib/rake.rb:2029:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exception_handling' /Library/Ruby /Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in
run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in
运行' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/bin/rake:19:in `load' /usr/bin/rake:19
这是我在课堂上想要搜索的内容:
searchable do
text :fname
text :mname
text :lname, :default_boost => 2 end
任何帮助将不胜感激!