Impressum / Imprint

Acts as ferret, continued

Posted on January 10, 2006

In my last post I forgot to mention how to create the initial ferret index. I have a little script for this in vendor/plugins/acts_as_ferret:

1
2
3
4
5
6
7
8
9

require 'ferret'

index = Ferret::Index::Index.new( :path => "#{RAILS_ROOT}/index/contents", :create => true )

Content.find_published.each { |content| index << content.to_doc }
index.flush
index.optimize
index.close

Calling this with


RAILS_ENV=production script/runner 'require "vendor/plugins/acts_as_ferret/rebuild_index"'

will rebuild the index from all existing Articles, Comments and Pages in your production database.

Comments
  1. JanPrillJanuary 23, 2006 @ 08:51 PM
    Great stuff! Thanks for sharing this, I'll definitly try it out! Regards Jan Prill