在Capistrano的Reindex太阳黑子Solr

pab*_*rti 4 capistrano ruby-on-rails sunspot sunspot-solr rvm-capistrano

我正在按照这个片段在Capistrano中添加Sunspot Solr https://gist.github.com/doitian/1795439并且它有效,但是当我运行cap solr:reindex它显示一个问题(如预期的那样)询问我是否要删除所有索引,所以我回答"是",但终端似乎在等待响应.

这是reindex的代码:

  desc "reindex the whole database"
  task :reindex, :roles => :app do
    stop
    run "rm -rf #{shared_path}/solr/data"
    start
    run "cd #{current_path} && #{rake} RAILS_ENV=#{rails_env} sunspot:solr:reindex" 
  end
Run Code Online (Sandbox Code Playgroud)

这是消息:

  * executing "cd /home/user/rapps/app/current && bundle exec rake RAILS_ENV=production sunspot:solr:reindex"
    servers: ["9.9.9.9"]
    [9.9.9.9] executing command
 ** [out :: 9.9.9.9] *Note: the reindex task will remove your current indexes and start from scratch.
 ** [out :: 9.9.9.9] If you have a large dataset, reindexing can take a very long time, possibly weeks.
 ** [out :: 9.9.9.9] This is not encouraged if you have anywhere near or over 1 million rows.
 ** [out :: 9.9.9.9] Are you sure you want to drop your indexes and completely reindex? (y/n)
y
Run Code Online (Sandbox Code Playgroud)

怎么可以避免这个消息?另外,我想用Cron运行这个rake,那么我以前怎么能给出答案或设置默认配置呢?重建索引的最佳/有效方法是什么?

提前致谢.

Eri*_*yes 6

我最近遇到了这个问题,发现这是一个有用的解决方法:

yes | bundle exec rake sunspot:reindex
Run Code Online (Sandbox Code Playgroud)