ThinkingSphinx exits, enters ActsAsSolrReloaded

I used to work with ThinkingSphinx until the day I needed to index documents with dynamic attributes. As Sphinx indexes data from the result of an SQL query, the goal didn’t seem possible.

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
  • highlighting
  • 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:

New features in ActsAsSolrReloaded from Diego Carrion on Vimeo.

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.

If you appreciate this work, please consider to recommend me at Working With Rails.

12 Comments »

  1. Have you looked at sunspot? http://github.com/outoftime/sunspot_rails

    Comment by Nadeem Bitar — January 19, 2010 @ 1:00 pm
  2. Hi Nadeem, I discovered it after I implemented the mentioned features in acts_as_solr_reloaded. I don’t know if it supports the same functionalities that acts_as_solr_reloaded has, but seems a cool option to be analyzed.

    Comment by dc.rec1 — January 19, 2010 @ 2:32 pm
  3. I’m guessing that there must have been other reasons you moved from sphinx to solr - sphinx can index dynamic data using the xmlpipe data source.

    Comment by Jeremy — January 19, 2010 @ 4:02 pm
  4. Have you taken a look at Sunspot and Sunspot Rails?

    Comment by james — January 19, 2010 @ 7:42 pm
  5. Oops, what Nadeem Bitar said.

    Comment by james — January 19, 2010 @ 7:43 pm
  6. Hi Jeremy, I didn’t know about the xmlpipe until now. I found this:

    http://www.sphinxsearch.com/docs/current.html#xmlpipe2

    When I had the problem, I tried to find something working with ThinkingSphinx but didn’t find anything. I just tried to discover if ThinkingSphinx supports xmlpipe2 but didn’t find any reference from the official repository, just this commit from a fork:

    http://github.com/ebeigarts/thinking-sphinx/commit/8ccd28995ba23b1ee506f226e9a6002f3d86bbee

    The principal reason I change Sphinx for Solr was the dynamic attributes, but another features I like are the live updating and that I can use it with any database, as they don’t communicate.

    Comment by dc.rec1 — January 19, 2010 @ 8:36 pm
  7. I know music is personal taste, but the music in your video actively prevented me from watching the video..
    Besides, good work!

    Comment by Fabio — January 20, 2010 @ 8:29 am
  8. Thanks for the feedback Fabio. In future videos I will not record the background music and just add something softly later :)

    Comment by dc.rec1 — January 20, 2010 @ 9:13 am
  9. You mention that it should be able to work with “any rails model”, but then it seems like it requires ActiveRecord. So it won’t really work with any rails model… only models derived from ActiveRecord. I’m trying to use with MongoDB and don’t use AR. I’ve already got sphinx working with Mongo thru xmlpipe, which works well. But I’d love to try out yours in comparison if it can work without requiring AR.

    Comment by Matt E. Patterson — January 20, 2010 @ 4:52 pm
  10. Hi Matt, I meant to say that it works with ActiveRecord on any database, sorry for don’t being explicit.

    Btw, are you using any plugin for Sphinx? Also, which adapter are you using for MongoDB?

    Thanks for your feedback, it was very good and I will try to adapt acts_as_solr_reloaded to work with Mongo.

    Comment by dc.rec1 — January 20, 2010 @ 5:28 pm
  11. [...] ThinkingSphinx exits, enters ActsAsSolrReloaded | Diego Carrion [...]

  12. [...] ThinkingSphinx exits, enters ActsAsSolrReloaded [...]

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2010 Diego Carrion | powered by WordPress with Barecity