I’m trying to make our application more resilient to downtime from our search server. To achieve this, I’m trying to disable the automatic indexing and removal, and manual perform them in a background process.
I’m trying
searchable :auto_index => false, :auto_remove => false do
...
end
But am still receiving a connection error, every time I try to save or destroy the record.
The backtrace shows that the error is coming from the solr searchable file, so it’s definetly sunspot_rails causing the problem. Here is a slice from the backtrace on destroy:
...
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'
...
Any idea why the options to disable these hooks aren’t working? Any idea how to actually disable them?
Thanks
Found the answer to my own question:
Turns out that while automatic callbacks were disabled, I was still making it dirty in a different step. sunspot_rails has a cleanup step that runs at the end of a request and tries to commit all dirty records to the solr server. To disable it add
auto_commit_after_request: falseto yoursunspot.yml.