How can I use Solr on Scalarium?

Using Solr with a Rails application works in a similar manner as setting up Sphinx on your Scalarium cloud. We supplied a cookbook that sets up Solr using Sunspot, and reconfigures your Rails application servers accordingly so that they always know where to find their index server.

We prepared an example cookbook to set up Solr in our repository, available for your perusal or customization. Add our cookbooks repository to your cloud, or add the cookbook to your own collection.

Start by adding a new role to your cloud called "Solr". It'll be the role your index server is going to have:

Solr Role

Add an instance to the role, and assign the custom recipe sunspot-solr::install for the setup event like so:

Solr Custom Recipes

For your Rails Application Servers, set up the recipe sunspot-solr::client to be run on deploy:

Rails Apps Custom Recipes

When you boot up the Solr instance the cookbook will set up a Solr instance on it, with a couple of default attributes, most noteworthy the memory limits, which default to 256M for the Java heap, and a maximum of 1024M for the stack. Adjust them to your liking and instance capacity in sunspot-solr/attributes/default.rb.

Now, every time you deploy, your Rails Application Servers will have a sunspot.yml file created so that they'll know which server to talk to. The index server will be picked automatically from the role "Solr".

We set up a small example application to see how Sunspot integrates in a Rails application. Apart from declaring the gems either as Scalarium dependencies or in your application, there's nothing else required on your part, Solr integration will work seamlessly. On the Solr index server, the Sunspot gem is installed automatically and doesn't need to be declared as a dependency.