新手问题 Sunspot 在 console 的时候 报错 请教各位大神了

ghn645568344 · 2016年03月19日 · 最后由 zgt 回复于 2016年07月25日 · 2282 次阅读

要做全文搜索,rails + mogo 参考的是https://ruby-china.org/topics/21473 这篇文章 当做到 建立索引

在console

  s = CompanyDatas.search do
    fulltext '张小三'
  end

  puts s.results

的时候报

D, [2016-03-20T00:02:57.613733 #12965] DEBUG -- :   SOLR Request (2.1ms)  [ path=select parameters={fq: ["type:CompanyDatas"], q: "张小三", fl: "* score", qf: "", defType: "edismax", start: 0, rows: 30} ]
Errno::ECONNREFUSED: Connection refused - {:data=>"fq=type%3ACompanyDatas&q=%E5%BC%A0%E5%B0%8F%E4%B8%89&fl=*+score&defType=edismax&start=0&rows=30", :method=>:post, :params=>{:wt=>:ruby}, :query=>"wt=ruby", :headers=>{"Content-Type"=>"application/x-www-form-urlencoded; charset=UTF-8"}, :path=>"select", :uri=>#<URI::HTTP:0x007f109f27b120 URL:http://localhost:8982/solr/development/select?wt=ruby>, :open_timeout=>nil, :read_timeout=>nil, :retry_503=>nil, :retry_after_limit=>nil}
    from /usr/local/lib/ruby/gems/2.1.0/gems/rsolr-1.0.13/lib/rsolr/connection.rb:19:in `rescue in execute'
    from /usr/local/lib/ruby/gems/2.1.0/gems/rsolr-1.0.13/lib/rsolr/connection.rb:14:in `execute'
    from /usr/local/lib/ruby/gems/2.1.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:182:in `execute'
    from /usr/local/lib/ruby/gems/2.1.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:176:in `send_and_receive'
    from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot_rails-2.2.4/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
    from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.5/lib/active_support/notifications.rb:164:in `block in instrument'
    from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.5/lib/active_support/notifications.rb:164:in `instrument'
    from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot_rails-2.2.4/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
    from (eval):2:in `post'
    from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot-2.2.4/lib/sunspot/search/abstract_search.rb:49:in `execute'
    from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot_rails-2.2.4/lib/sunspot/rails/searchable.rb:389:in `solr_execute_search'
    from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot_rails-2.2.4/lib/sunspot/rails/searchable.rb:165:in `solr_search'
    from (irb):1
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.5/lib/rails/commands/console.rb:110:in `start'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'

谷歌和百度也查了,没查出什么结果?请教各位大神了 或者 有教程了,也给下,拜托了

我也是这么写的,没有任何问题,跟这里的对比一下?

看到 Connection refused

会不会是没有启动 server

bundle exec rake sunspot:solr:start

#2 楼 @justin

Removing stale PID file at /home/haonan/xinsvn/rbspider/testmongo/solr/pids/development/sunspot-solr-development.pid
Successfully started Solr ...

这样算是启动成功了吗?帅哥

这是对的 成功启动

需要 登录 后方可回复, 如果你还没有账号请 注册新账号