Thinking Sphinx for Merb... And Rails


Update 2008-04-17
Pat’s integrated my changes and also removed the horrible double Rake task hack I did. Now the Rake task works automatically. I’ve removed my branch and now I mirror Pat’s master branch. Please use Pat’s branch instead as his one will always be the most up to date.

It started off this morning before breakfast when I wanted to get Pat’s excellent Thinking Sphinx plugin going in Merb. The next thing I know, it was all done with enough time to spare for some tea. However my first attempt I made was too tightly coupled with Merb when it didn’t need to be. So tonight I cleaned it up and now it’s flexible enough to be used on both Merb and Rails apps.

My experiment can be found here but I warn you to tread with care as it’s still work in progress. However it works quite well for me as we use both Rails and Merb at work. The gem is based on Thinking Sphinx trunk so please read that first if you have any problems.

To get going:


git clone git://github.com/jaikoo/thinking-sphinx.git

cd thinking-sphinx

rake package

sudo gem install pkg/thinking-sphinx.0.8.0.gem


In your Merb app add the following:

init.rb:
dependency 'thinking_sphinx'

Rakefile
require 'thinking_sphinx/tasks/merb
For your Rails app:

Create an file called search.rb in your iniitializers dir and insert:
require 'thinking_sphinx'

Add a file called thinking_sphinx.rake in lib/tasks and add:
require 'thinking_sphinx/tasks/rails

Then do the usual Thinking Sphinx setup such as adding the index info to your models, rake thinking_sphinx:configure, rake ts:index etc…

Thanks again to Pat Allan for creating such a well designed and abstracted Sphinx plugin.

Future? I’m eyeing up adding DataMapper support which I’m quite excited about… Hopefully I’ll get sometime in the next few days to work on this.

Update Pat announced the release of his re-write of the Thinking Sphinx plugin. Check it out here !

Meta

Posted by jonathan 2 months ago

Bookmark and Share

4 Responses to “Thinking Sphinx for Merb... And Rails”

  1. jney Graciously said:
    Nice, a full text search plugin for Merb. But i got an error while building the package (rake package) : ** README.txt is in the wrong format for auto-intuiting. run sow blah and look at it's text files rake aborted! Don't know how to build task 'lib/thinking_sphinx/tasks/merb_ts_tasks.rb'

  2. Sorry about that, can you do a pull and try it again. I forgot to push an updated to the manifest. Cheers Jonthan

  3. Also, when you rebuild the package it's best to delete all of the contents of the pkg dir otherwise you may can an error telling you to run sow.

  4. Great it just work nice. great work from you and pat allan.

Search


Archives


June 2008 (1)
May 2008 (1)
April 2008 (2)
March 2008 (4)
February 2008 (1)
January 2008 (1)
December 2007 (2)
November 2007 (5)
October 2007 (3)
September 2007 (4)
August 2007 (1)

Twitter


About


Online journal of Jonathan Conway a twenty something technologist, entrepreneur, husband, daddy of two, oh and lead architect at vzaar. Currently residing in London, UK.

You can find a little bit more about me here

Contact me at

Flickr


Holiday in Dubai Holiday in Dubai Holiday in Dubai My babies My babies Holiday in Dubai

Linkage


My tumbler
vzaar
Brightbox Rails Hosting
My Caboose Facebook Profile
New Bamboo
Luke Redpath
Jamie Van Dyke
Peter Cooper
Ismael
Caroline
Monster Gym
Scala
Pat Allan
Cristi Balan

Dopplr



I'm speaking at



I'm attending


dConstruct 2008 - Designing the Social Web

Sponsors


Brightbox Rails Hosting