Rails App: Solr Throwing Rsolr::Error::Http - 404 Not Found When Executing Search

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

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.

Capistrano: RSolr::Error::Http - 404 Not Found when reindexing Solr

Looks like your Solr server does not respond to the endpoint you expect. Your URL seems to be:
localhost:8983/solr/default (with the handler being /update under that).

Is there Solr endpoint there? Can you access it manually?

If not, I would recommend changing your start commands to log to a file instead of /dev/null and seeing what exceptions you get.

Rails 4 w/ Heroku RSolr::Error::Http (RSolr::Error::Http - 404 Not Found

Took me a full day of sifting through answers and I was just about to gut my application and remove solr altogether.

I solved it by going to my Heroku dashboard, clicking the Websolr addon icon which took me to the Websolr page for my heroku app. I deleted the index that was there by default and set up a new one with a new name.

Once the new index has been created, copy and paste the text in the field labeled Configure your Heroku Application

Lastly, I went to the terminal and entered these commands.

$ heroku config:add WEBSOLR_URL=[url_goes_here]

$ heroku restart

Everything works fine now.

Heroku - RSolr::Error::Http (RSolr::Error::Http - 404 Not Found

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)

Issues when upgrading to Rails 4 with Sunspot/Solr

So I ended up solving the problem, the following way.

  1. First I uninstalled all versions of sunspot and SOLR.
  2. Next I re-installed Sunspot with gem 'sunspot_rails'
    gem 'sunspot_solr'
  3. I then added solr.rake to application/lib/tasks
namespace :sunspot do
namespace :solr do
desc 'Start the Solr instance'
task :start => :environment do
case RUBY_PLATFORM
when /w(in)?32$/, /java$/
abort("This command is not supported on #{RUBY_PLATFORM}. " +
"Use rake sunspot:solr:run to run Solr in the foreground.")
end

if defined?(Sunspot::Rails::Server)
Sunspot::Rails::Server.new.start
else
Sunspot::Solr::Server.new.start
end
puts "Successfully started Solr ..."
end

desc 'Run the Solr instance in the foreground'
task :run => :environment do
if defined?(Sunspot::Rails::Server)
Sunspot::Rails::Server.new.run
else
Sunspot::Solr::Server.new.run
end
end

desc 'Stop the Solr instance'
task :stop => :environment do
case RUBY_PLATFORM
when /w(in)?32$/, /java$/
abort("This command is not supported on #{RUBY_PLATFORM}. " +
"Use rake sunspot:solr:run to run Solr in the foreground.")
end

if defined?(Sunspot::Rails::Server)
Sunspot::Rails::Server.new.stop
else
Sunspot::Solr::Server.new.stop
end
puts "Successfully stopped Solr ..."
end

task :reindex => :"sunspot:reindex"
end
end

It worked after that. Hopefully this helps someone.



Related Topics



Leave a reply



Submit