
Ferret is a Ruby implementation of the Apache Lucene text search engine, and like most things in Ruby on Rails using it in your application is extremely easy. Here is all you need to do:
  1. Open up a command line and install Ferret:
 gem install ferret
Â
  2. Then install the acts_as_ferret plugin in your Rails application folder:
ruby script/plugin install svn://projects.jkraemer.net/acts_as_ferret/tags/stable/acts_as_ferret
Â
  3. Crack open the model class that wraps the table that you want to search and add:
acts_as_ferret
For example, if you wanted to be able to search the bugs in an issue tracker you could add:
class Bug < ActiveRecord::Base
   acts_as_ferret :fields => [ 'description']
end
Where :fields specifies which fields you want to index. If you do not include this all of the fields will be indexed.
Â
   4.  then add something like the following to your controller class:
def search
   @bugs= Bug.find_by_contents(params[:query])
    render(:xml => @bugs.to_xml)
end
 Â
  5. lastly, you can call this method from Flex using an HTTPService.
For example, the following would return all of the bugs that contain the word ‘error’ in the description field:
searchBugs.send({query:"error"});