I decided then to take another look at Solr. Solr, differently from Sphinx, is an HTTP server and indexes data from posted XML documents. Each document can have a different structure, so it fits perfectly with the model of dynamic attributes.
Thiago Jackwin, aka RailsFreaks, created a plugin that integrates Rails with Solr called acts_as_solr. The plugin is very good, but Thiago disappeared from the map some time ago, he lost the domain, left GitHub and doesn’t answer emails any more. As a result of this, different forks and forks of forks have been created and the Git tree became a mess.
Annoyed with the situation of the project, I decided to fork the fork I liked the most and created a new repository called acts_as_solr_reloaded, with new features. This way, I hope the project gets easier to be found and that it gives more trust. I’m also compromising myself to keep the repository up to date and to pull contributions.
As today, the new features acts_as_solr_reloaded comes with are:
- support for dynamic attributes
- geo-localization or geo-spatial search
- integration with acts-as-taggable-on
- relevance ranking
To support geo-localization in Solr, it needed to be updated to the version 1.4 .
To make easier the experience of working with dynamic attributes and geo-localization, a few generators that setup the database were added to the project. You can use them like this:
script/generate dynamic_attributes_migration script/generate local_migration
You can after define your model this way:
class Document < ActiveRecord::Base acts_as_solr :dynamic_attributes => true, :spatial => true, :taggable => true end
Note that with :taggable => true you dont need to define your model as acts_as_taggable_on :tags, it’s done automatically.
To better demonstrate the new features in acts_as_solr_reloaded, I recorded a small video of five minutes showing the functionalities in action, hope you like it:
Note that in the video I used acts_as_taggable_on :tags and :taggable => true, at the time of the recording this both declarations were necessary, not anymore.