【问题标题】:Rails 4: RSolr::Error::Http (RSolr::Error::Http - 404 Not FoundRails 4:RSolr::Error::Http(RSolr::Error::Http - 404 未找到
【发布时间】:2013-12-16 17:40:24
【问题描述】:

我正在将我的应用程序升级到 Rails 4,现在有了我的 rails 服务器,以及 sunspot 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'):
  <a href="txmt://open?url=file:///Users/bashar/rails-projects/myapp/app/models/match.rb&amp;line=474&amp;column=1">app/models/match.rb:474:in `upcoming_games'</a>
  <a href="txmt://open?url=file:///Users/bashar/rails-projects/myapp/app/controllers/tickets_controller.rb&amp;line=34&amp;column=1">app/controllers/tickets_controller.rb:34:in `search'</a>


  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 是数据在正确的路径。我知道有类似的帖子,但他们的解决方案不起作用。我尝试评论path:,或者使用/solr/default,或者只使用/solr,或者使用ip而不是localhost都无济于事

有什么想法吗?关于如何查看 rails suntspot solr 请求试图到达的位置的提示?

【问题讨论】:

  • 我以前在升级版本和不同步时看到过这种情况。尝试从 sunspot.yml 中删除路径选项。您总是可以在错误行打开 gem,然后调试它。
  • 我也有同样的问题。到目前为止没有任何效果。
  • @sevenseacat 我已经尝试删除路径但没有运气。看起来是调试模式。
  • @climber247 只是为了确保我们遇到同样的问题,我的 sunspot-solr-development.log 文件没有错误。在升级到 Solr 1.4 期间,您需要更新一些配置文件。
  • 有警告但没有错误。你的解决方案对我不起作用。 :(

标签: ruby-on-rails ruby-on-rails-4 sunspot sunspot-rails sunspot-solr


【解决方案1】:

解决了!遵循答案suggested here 中的步骤,几乎没有改动:

  1. 停止所有正在运行的 solr 进程
  2. 删除 solr 文件夹但保留其副本以备不时之需,以防您需要一些旧配置、同义词等
  3. gem 卸载所有相关 gems
  4. 捆绑安装
  5. rails 生成 sunspot_rails:install
  6. 启动 solr
  7. reindex solr:现在我使用 mongoid,rake sunspot:reindex 似乎不起作用,但是从控制台开始执行 Sunspot.index!(Model.all) 对我来说是这样。

【讨论】:

  • 卸载 gems 是这里的关键 - 我完成了所有其他步骤,但这才是真正解决问题的方法。谢谢!
  • @xdotcommer 很高兴它对某人有所帮助,并感谢您进一步澄清。
【解决方案2】:

我遇到的问题是 gem 试图为 Jetty tempDirectory 使用它自己的 gem 目录,当然它没有写权限,所以服务器永远不会启动。它似乎在后台启动,但它并没有真正运行。当试图在前台运行它rake sunspot:solr:run 时,它会显示一些错误,但我仍然必须将它追踪到 gem 中的配置文件。您必须编辑 gem 配置来修复它。我在 GitHub 上添加了一个问题:

https://github.com/sunspot/sunspot/issues/561

问题是 sunspot_solr-2.1.0/bin/contexts/solr.xml 文件。您必须将 tempDirectory 设置为具有写入权限的内容,例如 /tmp,而不是 gem 目录中的 '.'。

如果您在启动 Solr 时仍然遇到问题,请尝试删除 tmp 目录并重新启动服务器。我有一个奇怪的情况,它指向 /tmp 目录并且正在工作,但是当我重新启动服务器时,它一直给我 404 错误!不知何故,它所依赖的所有文件都被删除了!由于该目录仍然存在,它没有重新复制 WAR 并展开它。如果删除 tmp 目录,那么它会重新复制并重新展开 WAR。

ls /tmp/solr-webapp/

这当然是在编辑 /usr/local/rvm/gems/ruby-2.0.0-p247.../gems/sunspot_solr-2.1.0/solr/contexts/solr.xml 文件之外。

【讨论】:

    【解决方案3】:

    我对这个问题的解决方法是: 在 config/sunspot.yml 配置文件中注释路径参数(默认配置)。

    默认为:#path: /solr/development.

    之后,

    • 停止solr的所有进程,

      ps aux | grep 'solr' 
      kill PROCESS_ID
      
    • 删除应用程序目录中的“solr”文件夹。

      rm -rf solr
      

    这将删除您以前的配置。

    • 那么,rake sunspot:solr:start

    • 启动solr服务器后再次尝试reindex,

          rake sunspot:reindex
      

    问题应该得到解决。

    我在我的一个项目中使用了 sunspot solr 全文搜索,并在其中解决了上述问题。

    例如参考链接-http://moreaboutsports.com/

    【讨论】:

    • 非常感谢。这个对我有用。我认为这是因为项目中的文件权限错误。我在临时服务器上工作,我总是遇到权限问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多