How to rebuild an index with act_as_ferret?

I use act_as_ferret (0.4.3) for full-text search, but when updating the index I need to restart

ferret, so is there any good way to make it updated automatically? thank!

+3
source share
1 answer

I got an answer

# ferret_index.rake
desc "Updates the ferret index for the application."
task :ferret_index => [ :environment ] do | t |
  MyModel.rebuild_index
  # here I could add other model index rebuilds
  puts "Completed Ferret Index Rebuild"
end 

This task is simplified: I say that to restore the entire index every hour. I assume that when my dataset gets big enough, it will be very slow. In this case, I will need to track all instances of the model that have been updated in the last hour, and simply index them.

, cron , , "production":

cd /rails_app && rake ferret_index RAILS_ENV=production 
+2

Source: https://habr.com/ru/post/1778579/


All Articles