Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

acts_as_solr Tutorial: More Search Goodness in Rails

By Peter Cooper / April 23, 2007

Solr
(photo credit: RBerteig)

A couple of months ago I posted about an acts_as_ferret tutorial, where Ferret is a Ruby port of Apache Lucene and acts_as_ferret provides almost automatic search features to any of your Rails models. It works great on a small scale but some people in the blogosphere pointed out that Ferret has a number of concurrency and stability issues (particularly on very large indexes).

Enter Solr. Solr is an open source 'server' based upon the actual Java version of Lucene which is well known for its stability. acts_as_solr therefore acts as a conduit between your Rails applications and a Solr/Lucene server meaning that you get full 'enterprise quality' search features based on proven software. Micha Wedemeyer has put together a great resource on how to install and setup Solr and acts_as_solr and the official acts_as_solr homepage has examples of how to use it within your own Rails applications. There's also a screencast called "Integrating Solr and the acts_as_solr plugin to any Rails app in less than 10 minutes" available to watch.

Comments

  1. ahFeel says:

    Ferret is going more and more stable these last weeks, there's still a little concurrency issue, but the index structure is, for now, freezed, so updates doesn't mean re-indexing anymore :) Even if it's still not as stable as Lucene, David BALMAIN is looking at this concurrency issue, so ferret's really going to get a stable release soon. By the way, ferret's faster than lucene ;)

  2. vlad says:

    > By the way, ferret's faster than lucene ;)
    Ferret is only faster at indexing. It's slower at searching.
    There is development work going on in Lucene to speed up indexing.

  3. Peter Cooper says:

    To someone who knows more about this than me.. why would Ferret be faster than Lucene at anything if Ferret is just a Ruby port of Lucene and Ruby is slower than Java (generally)? Just intrigued!

  4. Jerome says:

    Peter, Ferret does its indexing in C, not Ruby, so that's why its faster.

    http://ferret.davebalmain.com/trac/wiki/FAQ%3ADefinitions#WhatiscFerret

  5. Stijn Van Vreckem says:

    >>why would Ferret be faster than Lucene at anything if Ferret is just a Ruby port of >>Lucene and Ruby is slower than Java (generally)?

    Ferret is using the C port of lucene.

  6. Peter Cooper says:

    Aha.. thanks guys! :)

  7. Micah Wedemeyer says:

    Thanks for the link!

    If you are planning on using acts_as_solr in your Rails app, you will inevitably need at least two Solr indices (one for development, one for production).

    I have written a tutorial on a couple different ways to do this, including my favorite: two Solr instances in a single Tomcat container.

    Check out the howto at: http://blog.aisleten.com/2007/04/15/acts_as_solr-for-development-and-production-in-one-tomcat-instance/

  8. Paul Goscicki says:

    Unfortunately no one has thought about the children (think VPS) when they have brought the tanks (java, tomcat).

    Still it's great to see some competition in the ruby/rails database searching world. It will definitely help each project mature, especially ferret. What about mysql full text search?

Other Posts to Enjoy

Twitter Mentions