我正在将我的应用程序升级到Rails 4,现在得到了我的rails服务器,以及太阳黑子solr,经过大量的修补,运行后,我可以访问Solr管理页面.但是,当我尝试从我的rails开发应用程序访问solr进行搜索或索引时,我收到以下错误
RSolr::Error::Http (RSolr::Error::Http - 404 Not Found Error: Not Found Request Data: "fq=type%3AMatch&fq=date_in_utc_d%3A%7B2013%5C-11%5C-29T21%5C%3A00%5C%3A00Z+TO+%2A%7D&fq=approval__s%3AAPPROVED&sort=date_d+asc&q=london&fl=%2A+score&qf=caption_text%5E10+city_name_text%5E10+team_name_text%5E10+&defType=edismax&start=0&rows=30" Backtrace: /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/rsolr-1.0.9/lib/rsolr/client.rb:268:in `adapt_response' /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/rsolr-1.0.9/lib/rsolr/client.rb:175:in `execute' /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/rsolr-1.0.9/lib/rsolr/client.rb:161:in `send_and_receive' /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/sunspot_rails-2.1.0/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation' /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/notifications.rb:159:in `block in instrument' /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument' /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.1/lib/active_support/notifications.rb:159:in `instrument' /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/sunspot_rails-2.1.0/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation' (eval):2:in `post' /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/sunspot-2.1.0/lib/sunspot/search/abstract_search.rb:45:in `execute' /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/sunspot-2.1.0/lib/sunspot/session.rb:59:in `search'): app/models/match.rb:474:in `upcoming_games' app/controllers/tickets_controller.rb:34:in `search' Rendered /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.4ms) Rendered /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms) Rendered /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms) Rendered /Users/bashar/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (17.3ms)
这是sunspot.yml文件.
production: solr: hostname: ENV['WEBSOLR_URL'] port: 80 log_level: WARNING path: /solr/production # read_timeout: 2 # open_timeout: 0.5 development: solr: hostname: 192.168.0.11 port: 8981 log_level: INFO path: /solr/development test: solr: hostname: localhost port: 8981 log_level: WARNING path: /solr/test
我验证了solr数据是在正确的路径上.我知道有类似的帖子,但他们的解决方案不起作用.我试着评论路径:,或者使用/ solr/default,或只是/ solr,或使用ip而不是localhost无济于事
任何的想法?关于我如何看到导轨suntspot solr请求试图达到的提示?
解决了!此处建议的答案中的后续步骤几乎没有改动:
停止所有正在运行的solr进程
删除solr文件夹但是如果您需要一些旧的配置,同义词等,请保留它的副本.
宝石卸载所有相关的宝石
捆绑安装
rails生成sunspot_rails:安装
开始solr
reindex solr:现在因为我正在使用mongoid,rake sunspot:reindex似乎不起作用,但是从控制台开始做Sunspot.index!(Model.all)正在为我做这件事.
我对此问题的解决方法是:在config/sunspot.yml配置文件中注释path参数(默认配置).
默认是: #path: /solr/development.
在这之后,
停止solr的所有进程,
ps aux | grep 'solr' kill PROCESS_ID
删除应用程序目录中的"solr"文件夹.
rm -rf solr
这将删除以前的配置.
然后, rake sunspot:solr:start
启动solr服务器后再次尝试reindex,
rake sunspot:reindex
问题应该得到解决.
我使用了太阳黑子solr全文搜索我的一个项目,我已经解决了上述问题.
例如参考链接 - http://moreaboutsports.com/