Search code examples
ruby-on-railssolrsunspotsunspot-railssunspot-solr

Solr not reindexing correctly - Sunspot Solr with Solr 4


I have a similar issue that Solr with Rails - rake sunspot:reindex is not working.

I have these in my Gemfile:

gem 'sunspot_solr', github: 'sunspot/sunspot', branch: 'master'
gem 'sunspot_rails', github: 'sunspot/sunspot', branch: 'master'

And:

bundle exec rake sunspot:solr:start

works fine, but when I do:

bundle exec rake sunspot:solr:reindex

I get:

Connection refused - {:data=>
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:Service</query></delete>",
:headers=>{"Content-Type"=>"text/xml"}, :method=>:post, :params=>{:wt=>:ruby},
:query=>"wt=ruby", :path=>"update", :uri=>
#<URI::HTTP:0x007fccf982f348 URL:http://localhost:8982/solr/default/update?wt=ruby>,
:open_timeout=>nil, :read_timeout=>nil, :retry_503=>nil,
:retry_after_limit=>nil}

Solution

  • I added path to sunspot.yml

    development:
      solr:
        hostname: localhost
        port: 8982
        log_level: INFO
        path: /solr/development
    
    test:
      solr:
        hostname: localhost
        port: 8981
        log_level: WARNING
        path: /solr/test
    

    Not sure if this good enough though. Seems this is because I am using Solr 4 and configuration is creating solr/environment type URLs.