I’m on Rails 4 and here’s my config/sunspot.yml
test:
solr:
hostname: localhost
port: 8981
log_level: WARNING
path: /solr/test
pid_dir: <%= File.join(::Rails.root, ‘tmp’, ‘pids’)%>
auto_index_callback: after_commit
auto_remove_callback: after_commit
On circleci I always get the errors because of solr:
RSolr::Error::Http:
RSolr::Error::Http - 404 Not Found
Error: Not Found
URI: http://localhost:8981/solr/test/update?wt=ruby
How to fix it?
I was having the same problem and nothing else I tried was working, but I finally solved it. Hopefully this will help someone else.
The default sunspot.yml
that CircleCI generates doesn’t seem to be appropriate for their own Solr setup. It creates a sunspot.yml
with port 8981 but their solr seems to run on 8982.
This is the bare minimum setup I could find that would actually work, based on a Rails app I built from scratch to reproduce the problem, which I then ported to the actual app. All of these settings are required.
Create the file config/sunspot.circleci.yml
:
test:
solr:
hostname: localhost
port: 8982
path: /solr/default
and put this in /circle.yml
:
database:
override:
- cp config/sunspot.circleci.yml config/sunspot.yml
- bundle exec rake db:create db:schema:load sunspot:solr:start
After that, it worked! Finally!