retire
retire copied to clipboard
Update index without ActiveRecord callbacks
How can I update an index document? I cannot use Tire::Model::Callbacks
What is the scenario in which you need to update the index? Is this while the app is running or is this stand alone index sanitization ?
And also, out of curiosity, why can't you use the callbacks ?
We want to keep DB data in sync with the index hence the update. We have some specific requirements so cannot use callbacks.
bundle exec rake environment tire:import CLASS="Model" INDEX="INDEX_NAME" FORCE=true
Should do it
I figured it out here - https://github.com/karmi/tire/blob/master/examples/tire-dsl.rb#L748
Tire.index 'users' do
update 'user', "1", doc: { country: 'US' }
end
Also is there a DSL to do "script" updates to documents? So something like this (see counter & tags example) - http://www.elasticsearch.org/guide/reference/api/update/
Ah ok I see it - https://github.com/karmi/tire/pull/366
@kapso The integration test, rather: https://github.com/karmi/tire/blob/master/test/integration/index_update_document_test.rb. So, closing the issue?