我正在使用ACTS_AS_FERRET(0.4.3)进行全文搜索,但是当更新索引时,我需要重新启动

雪貂,那么是否有任何使其自动更新的好方法?谢谢!

有帮助吗?

解决方案

我得到答案

# 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 

简化了此任务:我告诉它每小时重建整个索引。我猜想我的数据集足够大,这真的很慢。在这种情况下,我需要跟踪过去一个小时内更新的所有模型实例,然后将其索引。

最后,我需要一份cron工作来运行耙子任务,确保将环境设置为“生产”:

cd /rails_app && rake ferret_index RAILS_ENV=production 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top