-->

Heroku - RSolr::Error::Http (RSolr::Error::Http -

2019-09-01 07:45发布

问题:

In config/sunspot.yml

production:
  solr:
    hostname: http://index.websolr.com/solr/...
    port: 8983
    log_level: WARNING
    path: /solr/production
...

And my Heroku config variable is

http://index.websolr.com/solr/...

And everything else seems to be configured as per the docs, but I keep getting 404 messages in the log and app crashes. Has anyone come across this before and managed to fix it?

回答1:

To clarify, Sunspot comes bundled with Solr by default, but that is completely separate from your websolr index. Websolr indices are managed through a dashboard that you can see by running heroku addons:open websolr. All of the configuration settings are applied there; you can't start/stop/restart websolr from the command line.

Per the documentation:

By default, Sunspot 1.3.0 supports the WEBSOLR_URL environment variable used by your Heroku application in production. This lets Sunspot perform actions on your index without further configuration, allowing users to get search up and running quickly without necessitating changes to their app’s codebase.

If you would like more fine-grained control over which Solr servers you are using in different environments, you may run script/generate sunspot from a command line in your application’s root directory to create a Sunspot configuration file at config/sunspot.yml.

So you should be able to simply remove the sunspot.yml file and Sunspot will simply use the value of your WEBSOLR_URL. Alternatively, you could use something like this:

production:
   solr:
     hostname: index.websolr.com
     port: 80
     log_level: WARNING
     path: /solr/a1b2c3d4e5 (whatever your key is)


回答2:

Try this:

  1. Stop Solr
  2. Remove solr folder from your project folder
  3. Change 'path: /solr/production' to: 'path: /solr/default'
  4. Reboot the machine
  5. Start solr

Its weird, but works for me.