Heroku

How It Works

Full Text Search Options on Heroku

Last Updated: 08 February 2012

search

Table of Contents

Heroku recommends using an add-on to provide full-text search. This provides you with the best performance, scalability, and ease-of-use for your application. There are two add-ons for full text search: Flying Sphinx, Searchify and Websolr.

Flying Sphinx

Flying Sphinx provides customizable, real-time search. The Heroku Flying Sphinx add-on enables you to quickly begin indexing and searching in minutes, by just installing the add-on and running the appropriate gems.

Searchify IndexTank

Searchify IndexTank provides fast full-text search to your application with easy to tune your search results ranking using powerful custom scoring functions

Websolr

Websolr is a managed search service run by Onemorecloud. The Heroku Websolr add-on provides complete integration: all you need to do is install the add-on and use the websolr-acts_as_solr or websolr-sunspot_rails gem from your app.

Run Your Own Solr Server

You can also run a Solr server on your own, either from an EC2 instance (ideal for minimizing latency), or on any internet-connected server. Steps to set up Solr:

  • Install the Java runtime environment. On Debian or Ubuntu this can be done with: apt-get install sun-java6-jre
  • git clone git://github.com/mattmatt/acts_as_solr.git
  • cd acts_as_solr/solr && java -jar start.jar

The server will now be running on port 8983. Test it with a web client, such as:

$ curl localhost:8983 

which should produce a 404.

Then to set up a Rails app to access it:

  • script/plugin install git://github.com/mattmatt/acts_as_solr.git
  • Add acts_as_solr to the model. Specify which fields you want to index - otherwise it will try to index everything, which may cause problems with date fields. For example: acts_as_solr :fields => [ :title, :body ]
  • Edit config/solr.yml and set production to use the IP of your Solr server and port 8983.
  • Deploy your app to Heroku with git push.
  • Run heroku rake solr:reindex to generate the index for any existing records in your database.
  • Try it out with something like: heroku console "Post.find_by_solr('some text')"

Further reading: http://www.quarkruby.com/2007/8/12/acts_as_solr-for-search-and-faceting