Recipes: Ferret

Ferret (http://ferret.davebalmain.com/trac) is a high-performance, full-featured text search engine library written for Ruby.

It is inspired by Apache Lucene Java project.

acts_as_ferret comes with a built in DRb server that acts

as the central hub for all indexing and searching in your application.

Ferret now comes with a recipe for managing your Drb server. The Ferret config file is located at config/ferret_server.yml and

looks like this:

production:
host: ferret.yourdomain.com
port: 9009
pid_file: log/ferret.pid

The supplied recipe looks like this

namespace :ferret do
desc “Stop the Ferret server, and continue even if the operation fails.”
task :stop_safe, :roles => :app, :o n_error => :continue do
top.ferret.stop
end

desc “Start Ferret Server”
task :start, :roles => :app do
top.ferret.start
end

desc “Stop Ferret Server”
task :stop, :roles => :app do
top.ferret.stop
end

desc “Restart Ferret Server”
task :restart, :roles => :app do
top.ferret.restart
end

desc “Rebuild the Ferret index”
task :rebuild, :roles => :app do
run “cd #{current_path} && rake production ferret:rebuild”
end

desc “Destroy the Ferret index”
task :destroy, :roles => :app do
run “cd #{current_path} && rm -rf index/production index/development index/test”
end

end

Leave a Reply