views:

436

answers:

6

I have a small site with about 500 photos and 150 visitors per day which is hosted on Dreamhost. I would like to add a simple search engine that does not need to run long time processes which are not allowed on shared host.

The search engine should process different fields belonging to various models: Photo, Photo.author.name, Photo.comments.content and many others

Is there any plugin that can help?

+1  A: 

acts_as_ferret will most likely serve you well.

But I don't know if and how Ferret will perform on a setup like yours.

Koraktor
I was under the impression that Ferret ran as a background process.
tadman
Does anyone know whether Ferret require a background process?
collimarco
You need to run the DRb server in production. Ferret is a turd and you should look for something else that doesnt have so many problems.
Mark Stahler
+2  A: 

The full-text search feature of MySQL, which is generally available on any shared hosting environment, is a great way to add this kind of functionality. The only downside is that it works only on MyISAM tables which have generally been deprecated in favor of InnoDB.

The approach that I have seen work, where a great example is the Wikipedia database architecture, is to create derivative copies of model records specifically for searching purposes. These need to be kept in sync with the main record, but that's easily done with an after_save handler or a simple SQL update statement.

One note is that ActiveRecord is not capable of understanding full-text indexes. A rather ugly extension is required to make it cooperate, though I do have an example bundled up in a collection of MySQL hacks:

http://github.com/theworkinggroup/rails_mysql_hacks/tree/master

tadman
A: 

You might want to look into Sphinx/Thinking Sphinx for fast full-text search.

Thinking Sphinx

I don't know if installing Unix packages and that whole process is overkill for what you're looking for on Dreamhost, but it's a very fast and robust solution that will serve your needs well in the future.

Bryan Woods
Sphinx works really well but does need a daemon :(
collimarco
+1  A: 

Ferret or sphinx WILL need dedicated background process. Your only option seems like mysql full text search with proper indexes.

Hemant Kumar
+2  A: 

There are at least 3 full-text search engines for Rails:

Which one is the best choice? It depends. Here you can read a comparison between sphinx and ferret, including a comment from Engine Yard.

Simone Carletti
They all require background processes...
collimarco
+2  A: 

I think that the acts_as_indexed plugin is the best bet for your needs. It doesn't require a separate server; it creates it index automatically in the filesystem. On a site similar to yours, it was plenty fast and easy to configure.

Dogweather