Acts As Fulltextable plugin

Plugin details

Acts As Fulltextable allows you to create an auxiliary to be used for full-text searches. It behaves like a polymorphic association, so it can be used with any ActiveRecord model.

Websitehttp://blog.wonsys.net/posts/26-our-first-plugin-acts_as_fulltextable/ Repositoryhttp://wonsys.googlecode.com/svn/plugins/acts_as_fulltextable Tags Search, FullText LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install http://wonsys.googlecode.com/svn/plugins/acts_as_fulltextable

Add the following code to the model that should be included in searches:

acts_as_fulltextable :fields, :to, :include, :in, :index



Create the migration:

script/generate fulltext_rows model1 model2 model3 ...



Then execute it:

rake db:migrate



You can either run a search on a single model:

Model.find_fulltext('query to run', :limit => 10, :offset => 0)



Or you can run it on more models at once:

FulltextRow.search('query to run', :only => [:only, :this, :models], :limit => 10, :offset => 0)



Warning

Should you add acts_as_fulltextable to a new model after the initial migration was run,
you should execute the following piece of code (a migration or script/console are both fine):

NewModel.find(:all).each {|i| i.create_fulltext_record}



It will add all of the model's instances to the index.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: Guest, 6 months ago