Skip to content

Instantly share code, notes, and snippets.

@1v
Created February 15, 2017 10:52
Show Gist options
  • Save 1v/8a04e74ed1e86d8c52cf007f77b178be to your computer and use it in GitHub Desktop.
Save 1v/8a04e74ed1e86d8c52cf007f77b178be to your computer and use it in GitHub Desktop.
Rails 5 Sunspot Install

Add to Gemfile:

gem 'sunspot_rails'
gem 'sunspot_solr' # optional pre-packaged Solr distribution for use in development

Bundle it!

bundle update

Generate a default configuration file:

bin/rails generate sunspot_rails:install

Change config/sunspot.yml to:

production:
  solr:
    hostname: localhost
    port: 8983
    log_level: WARNING
    path: /solr/default
development:
  solr:
    hostname: localhost
    port: 8983
    log_level: INFO
    path: /solr/default
test:
  solr:
    hostname: localhost
    port: 8983
    log_level: WARNING
    path: /solr/test

Start Solr:

bundle exec rake sunspot:solr:start

Reindex:

bundle exec rake sunspot:solr:reindex

Block access to web interface:

iptables -A INPUT -p tcp -s localhost --dport 8983 -j ACCEPT && iptables -A INPUT -p tcp --dport 8983 -j DROP && iptables-save > iptables.rules && iptables-restore < iptables.rules && rm iptables.rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment