Rails app: Solr throwing RSolr::Error::Http - 404 Not Found when executing search

独自空忆成欢 提交于 2019-11-28 18:14:19

I came across the same issue when upgrading to sunspot 2.1.0 from 2.0.0.

I resolved this by adding following line to sunspot.yml (under config in my rails app) on the development: block (maybe one is needed for test and production )

    solr_home: solr

So my SOLR installation is under rails-app-dir/solr and the configuration there under conf.

vutran

These are the terminal commands you should follow to solve your problems:

  1. ps aux | grep solr to get solr process ID
  2. sudo kill <ID>, <ID> is the ID you found from 1
  3. rm -r <path/to/solr>, remove the solr directory inside your project to remove all of previous indexes
  4. RAILS_ENV=production bundle exec rake sunspot:solr:start
  5. Change the path to /solr/default inside config/sunspot.yml
    development:
      solr:
        hostname: localhost
        port: 8982
        log_level: INFO
        path: /solr/default
    
  6. RAILS_ENV=production bundle exec rake sunspot:solr:reindex

Bam! Problems solved! I hope.

I've been looking forever for the answer to this issue, and to understand why the SOLR Admin page was crashing. Here's the solution for this problem when upgrading sunspot solr from 2.0.0 to 2.1.0:

Add this entry to your development section of the sunspot.yml: solr_home: solr like the follwoing example ...

development:
  solr:
    hostname: localhost
    port: 8982
    log_level: INFO
    path: /solr/development
    solr_home: solr

Did someone check in the ./solr directory with your project?

If so, delete it, run rails g sunspot_rails:install and then start your server again.

This one's bit me twice now.

@Marko Taponen's solution worked for me for a while, but now I'm back, because this problem reared its ugly head again, this time in my rpsec/capybara tests.

Here's what fixed it for me:

On the command line:

bundle exec rake sunspot:solr:stop

After doing this, I ran my tests again, and it worked.!

development:
  solr:
    hostname: localhost
    port: 8982
    log_level: INFO
    path: /solr
  auto_index_callback: after_commit
  auto_remove_callback: after_commit

Also check if schema.xml is loaded from your gem file or from your solr directory in root of the app! You might end up changing schema.xml several times, but it would be the wrong file that is loaded.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!