September 3, 2012

SolrSail: Solr from scratch in 3 lines

SolrSail can run Solr from scratch in 3 lines (requires JRuby):

gem install solr_sail
solrsail install
solrsail start

When you run solrsail install there will be a fair amount of output, as Jar dependencies are downloaded and the Solr config directory is extracted to the default path of solr.

When solrsail start is called, Solr will start up using the solr dir for configuration.

Now you can visit http://localhost:8983/solr and see the fruit of your labor.

Additional configuration options are detailed at

The innards

Solr is run using an embedded Jetty server. There are only 3 Java classes used to make this work. This is really a showcase for the power of LockJar.

SolrSail relies heavily upon LockJar to manage the 57 Jar dependencies required to setup and run Solr. Packaged with the solr_sail.gem is a Jarfile.lock that contains all the Jar dependencies. As part of the install, LockJar uses the Jarfile.lock to check that the Jar dependencies exist and download missing one. For the start call, LockJar populates the Classpath based on Jarfile.lock.

Developing SolrSail was amazingly easy*. I used Maven for all the Jar dependencies, which integrates nicely with Eclipse. All I need to do to tie my Java with JRuby was create the following 1 line Jarfile for LockJar:

pom 'pom.xml'

When LockJar locks the Jarfile, the Maven pom.xml is parsed for dependencies, a list of transitive Jar dependencies is created as the Jarfile.lock. In my Ruby, I have LockJar load all the Jar dependencies and I have full access to the my Java.

All in One step

This scenario works well, because it has two steps: install than start. Very similar to how Bundler works. This allows all the Jar dependencies to be downloaded separately before the start. It is possible to combine all of this into one step, the only downside is that LockJar would check that Jar dependencies exist every time (which may not be a bad thing).

*Developing the Ruby was easy once I created a Rakefile that works with a Maven style layout

Comments (View)
blog comments powered by Disqus