我正在使用rails 5开发一个API项目,我已经安装了太阳黑子 gem用于搜索,但现在我收到了错误
RSolr :: Error :: ConnectionRefused:拒绝连接
当我尝试更改记录中的任何字段或创建新记录时,在rails控制台中完整的错误日志:
RSolr::Error::ConnectionRefused: Connection refused - {:data=>"<?xml version=\"1.0\" encoding=\"UTF-8\"?><add><doc><field name=\"id\">Event 147</field><field name=\"type\">Event</field><field name=\"type\">ApplicationRecord</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">Event</field><field boost=\"5\" name=\"title_text\">new Event around</field><field name=\"desc_text\">something</field><field name=\"location_text\">12134</field></doc></add>", :headers=>{"Content-Type"=>"text/xml"}, :method=>:post, :params=>{:wt=>:ruby}, :query=>"wt=ruby", :path=>"update", :uri=>#<URI::HTTP http://localhost:8982/solr/development/update?wt=ruby>, :open_timeout=>nil, :read_timeout=>nil, :retry_503=>nil, :retry_after_limit=>nil}
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rsolr-1.1.1/lib/rsolr/connection.rb:19:in `rescue in execute'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rsolr-1.1.1/lib/rsolr/connection.rb:14:in `execute'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rsolr-1.1.1/lib/rsolr/client.rb:181:in `execute'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rsolr-1.1.1/lib/rsolr/client.rb:175:in `send_and_receive'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sunspot_rails-2.2.5/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/notifications.rb:164:in `block in instrument'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/notifications.rb:164:in `instrument'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sunspot_rails-2.2.5/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
from (eval):2:in `post'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rsolr-1.1.1/lib/rsolr/client.rb:84:in `update'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rsolr-1.1.1/lib/rsolr/client.rb:104:in `add'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sunspot-2.2.5/lib/sunspot/indexer.rb:127:in `add_documents'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sunspot-2.2.5/lib/sunspot/indexer.rb:134:in `add_batch_documents'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sunspot-2.2.5/lib/sunspot/indexer.rb:26:in `add'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sunspot-2.2.5/lib/sunspot/session.rb:91:in `index'
... 29 levels...
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands/console_helper.rb:9:in `start'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands/commands_tasks.rb:78:in `console'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands.rb:18:in `<top (required)>'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/dependencies.rb:293:in `require'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/dependencies.rb:293:in `block in require'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/dependencies.rb:293:in `require'
from /home/mcd/RailsProjects/carpool/bin/rails:9:in `<top (required)>'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/dependencies.rb:287:in `load'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/dependencies.rb:287:in `block in load'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/dependencies.rb:287:in `load'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/mcd/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
在我的宝石文件中我包括
gem 'sunspot_rails'
并在开发小组中
gem 'sunspot_solr'
gem 'progress_bar'
更新: 当我尝试重新索引时
RSolr::Error::ConnectionRefused: Connection refused - {:data=>"<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:Event</query></delete>", :headers=>{"Content-Type"=>"text/xml"}, :method=>:post, :params=>{:wt=>:ruby}, :query=>"wt=ruby", :path=>"update", :uri=>#<URI::HTTP http://localhost:8982/solr/development/update?wt=ruby>, :open_timeout=>nil, :read_timeout=>nil, :retry_503=>nil, :retry_after_limit=>nil}
(eval):2:in `post'
Errno::ECONNREFUSED: Failed to open TCP connection to localhost:8982 (Connection refused - connect(2) for "localhost" port 8982)
(eval):2:in `post'
Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 8982
(eval):2:in `post'
Tasks: TOP => sunspot:solr:reindex => sunspot:reindex
答案 0 :(得分:6)
我忘了执行命令
rake sunspot:solr:run
希望帮助像我这样的太阳黑子/ solr的新人