【问题标题】:Sunspot_rails isn't respecting :auto_index and :auto_removeSunspot_rails 不尊重 :auto_index 和 :auto_remove
【发布时间】:2012-07-18 16:54:29
【问题描述】:

我正在努力使我们的应用程序对搜索服务器的停机时间更具弹性。为此,我尝试禁用自动索引和删除,并在后台进程中手动执行它们。

我在努力

searchable :auto_index => false, :auto_remove => false do
...
end

但每次我尝试保存或销毁记录时仍然收到连接错误。

回溯显示错误来自 solr 可搜索文件,因此肯定是 sunspot_rails 导致了问题。这是销毁时回溯的一部分:

...
rsolr (1.0.8) lib/rsolr/client.rb:67:in `update'
rsolr (1.0.8) lib/rsolr/client.rb:121:in `delete_by_id'
sunspot (1.3.3) lib/sunspot/indexer.rb:36:in `remove'
sunspot (1.3.3) lib/sunspot/session.rb:137:in `block in remove'
sunspot (1.3.3) lib/sunspot/session.rb:136:in `each'
sunspot (1.3.3) lib/sunspot/session.rb:136:in `remove'
sunspot (1.3.3) lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `remove'
sunspot (1.3.3) lib/sunspot.rb:410:in `remove'
sunspot_rails (1.3.3) lib/sunspot/rails/searchable.rb:390:in `solr_remove_from_index'
sunspot_rails (1.3.3) lib/sunspot/rails/searchable.rb:93:in `block in searchable'
...

知道为什么禁用这些挂钩的选项不起作用吗?知道如何实际禁用它们吗?

谢谢

【问题讨论】:

    标签: ruby-on-rails sunspot sunspot-rails


    【解决方案1】:

    找到了我自己问题的答案:

    事实证明,虽然自动回调被禁用,但我仍然在不同的步骤中弄脏了它。 sunspot_rails 有一个清理步骤,在请求结束时运行,并尝试将所有脏记录提交到 solr 服务器。要禁用它,请将auto_commit_after_request: false 添加到您的sunspot.yml

    【讨论】:

    • 感谢@Forrest 提供的有用信息
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    • 2016-10-13
    • 1970-01-01
    • 2012-01-10
    • 1970-01-01
    相关资源
    最近更新 更多