Jens Krämer

Faster indexing with acts_as_ferret

 |  ferret, ruby, rails  |  2 comments

Does your application operate on large chunks of records that are indexed by acts_as_ferret? If the answer is yes, then this is for you:

By combining two brand new features of acts_as_ferret you may now speed up batch operations like this: First, disable acts_as_ferret indexing for the model class in question. Then do your updates, but be sure to remember the primary keys of the modified records. After that, re-enable acts_as_ferret and index all modified or created records at once:

Model.disable_ferret # create or modify records here, collect ids in id_array Model.enable_ferret Model.bulk_index(id_array)

You may also use the block syntax to have aaf be re-enabled automatically:

id_array = [] Model.disable_ferret do # create or modify records here, collect ids in id_array end Model.bulk_index(id_array)


Bojan Mihelac

Hi Jens, does it make sense to call disable_ferret from enironment.rb to stop automatic indexing?


Yes, doing so will stop acts_as_ferret from indexing any new or changed records.

You can use Markdown here.

For the sake of spam checking any data you submit, including your IP address, will be transferred to the US based Akismet web service ( If that's not acceptable for you, you can also reach me by other means.