【问题标题】:Reindex Sunspot Solr in Capistrano在 Capistrano 中重新索引太阳黑子 Solr
【发布时间】:2013-03-16 21:27:49
【问题描述】:

我正在关注这个 sn-p 以在 Capistrano https://gist.github.com/doitian/1795439 添加 Sunspot Solr 并且它可以工作,但是当我运行 cap solr: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

这是消息:

  * 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

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

提前致谢。

【问题讨论】:

    标签: ruby-on-rails capistrano sunspot sunspot-solr rvm-capistrano


    【解决方案1】:

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

    yes | bundle exec rake sunspot:reindex
    

    【讨论】:

      【解决方案2】:

      pull request 现已合并到太阳黑子宝石上。您应该可以使用rake sunspot:reindex[,,true] 来触发静音重新索引。

      再次memes save the planet

      【讨论】:

        【解决方案3】:

        查看 sunspot_rails 源代码后,目前无法强制绕过此消息。见the rake task code defined here

        已经(一个月前)(Pull request here) 提交了一个拉取请求,要求 rake 任务支持 silent 选项,但它还没有被合并。

        我会:

        1. fork sunspot gem Repo located here 并自己对 rake 任务进行更改(然后更改环境 Gemfile 以使用您的 fork gem)。
        2. 向您的 Capistrano 任务添加一个睡眠命令(大约 10 秒,比此命令出现应该花费的时间更长),然后为标准输入提供“y”

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-03-29
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多