gpt4 book ai didi

ruby-on-rails - 由于 "404 Not Found"错误,sunspot_rails 无法索引

转载 作者:行者123 更新时间:2023-12-04 15:20:23 26 4
gpt4 key购买 nike

我正在尝试在一个小型 Rails 应用程序中安装 Sunspot,完全遵循 gem setup instructions ,但每次遇到RSolr::Error::Http: RSolr::Error::Http - 404 Not Found尝试索引数据时出错。我可以用一个新的应用程序重现这个;这是我遵循的确切步骤:

创建一个新的 Rails 4.2.5 应用程序:

$ rails new test_sunspot
$ cd test_sunspot/
$ spring stop # spring can cause `generate` commands to hang
$ rails g model Thing title:string
$ rake db:migrate
$ rails c
> Thing.create!(title: "Cats")
> Thing.create!(title: "Pizza")
> exit

向模型添加太阳黑子指数:
class Thing < ActiveRecord::Base
searchable do
text :title
end
end

将太阳黑子添加到 Gemfile:
...
gem 'sunspot_rails', '2.2.2'
gem 'sunspot_solr', '2.2.2'
...

安装、启动和重新索引 Sunspot:
$ bundle install
$ rails g sunspot_rails:install # default sunspot.yml is not changed
$ ps aux | grep solr # confirm that no Solr services are running
$ bundle exec rake sunspot:solr:start # generates solr/ dir; no errors
$ bundle exec rake sunspot:solr:reindex

此 reindex 命令产生以下输出。当我进入 Rails 控制台并尝试创建一个新的 Thing 对象时,它触发了相同的错误(因为 Sunspot 尝试更新索引):
Skipping progress bar: for progress reporting, add gem 'progress_bar' to your Gemfile
rake aborted!
RSolr::Error::Http: RSolr::Error::Http - 404 Not Found
Error: Not Found

URI: http://localhost:8982/solr/development/update?wt=ruby
Request Headers: {"Content-Type"=>"text/xml"}
Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:Thing</query></delete>"

Backtrace: /Users/topher/.rvm/gems/ruby-2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:284:in `adapt_response'
/Users/topher/.rvm/gems/ruby-2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:190:in `execute'
/Users/topher/.rvm/gems/ruby-2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:176:in `send_and_receive'
# ...lots of backtrace omitted...
/Users/topher/.rvm/gems/ruby-2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/tasks.rb:19:in `block (2 levels) in <top (required)>'
/Users/topher/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
/Users/topher/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => sunspot:solr:reindex => sunspot:reindex
(See full trace by running task with --trace)
ps aux | grep solr的输出(启动Solr后):注意 solr/pids/development/sunspot-solr-development.pid中提到的PID是 62449 , 匹配第三行:
topher          62617   0.0  0.0  2432772    520 s002  R+    3:00PM   0:00.00 grep solr
topher 62484 0.0 1.3 3274624 105756 ?? S 2:57PM 0:03.65 /usr/bin/java -server -Xss256k -Xms512m -Xmx512m -XX:NewRatio=3 -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=8 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 -XX:+CMSScavengeBeforeRemark -XX:PretenureSizeThreshold=64m -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=50 -XX:CMSMaxAbortablePrecleanTime=6000 -XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/Users/topher/.rvm/gems/ruby-2.2.0/gems/sunspot_solr-2.2.2/solr/server/logs/solr_gc.log -DSTOP.PORT=7982 -DSTOP.KEY=solrrocks -Djetty.port=8982 -Dsolr.solr.home=/Users/topher/Sites/john_kole/test_sunspot/solr -Dsolr.install.dir=/Users/topher/.rvm/gems/ruby-2.2.0/gems/sunspot_solr-2.2.2/solr -Duser.timezone=UTC -Djava.net.preferIPv4Stack=true -jar start.jar
topher 62449 0.0 0.0 2444632 1304 ?? Ss 2:57PM 0:00.04 bash ./solr start -f -p 8982 -s /Users/topher/Sites/john_kole/test_sunspot/solr

其他详情:
  • 我在 Mac OSX Yosemite 上
  • 我已经卸载并重新安装了相关的 gem,尝试降级到 Sunspot 1.3.0,甚至运行 gem pristine --all , 结果没有变化
  • 编辑 :我已经阅读了有关 Sunspot/Solr 404 Not Found 错误的其他类似票证。看起来这些情况下的解决方案相当于“重置”Solr 配置,并且与新的(开发环境)项目无关:在我运行 rake sunspot:solr:start; 之前没有运行任何先前的 Solr 实例;这是一个全新的 Rails 项目,所以无论如何 solr/目录都是新生成的;这是在开发中,而不是生产中;并添加 solr_home: solrsunspot.yml或更新 path: /solr/default对 404 结果没有影响。

  • 问题:
  • 知道为什么会这样吗?
  • 这种损坏可能是由于我的 OSX 环境中安装错误造成的吗?我应该看什么?
  • 按照这些相同的步骤,您能否让 Sunspot 在全新安装的当前 Rails 上正常工作?

  • 提前致谢!

    最佳答案

    删除 sunspot_solr通过以下命令在您的机器上安装 gem 和 install solr

    brew install solr

    如果它不起作用运行 brew update首先获取最新的solr链接

    brew 将自动安装所有缺少的依赖项。

    启动solr:
    solr start

    关于ruby-on-rails - 由于 "404 Not Found"错误,sunspot_rails 无法索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34075303/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com