Remove ActiveRecord model from ElasticSearch index with tire gem
Say, we have an ActiveRecord model Ticket
class Ticket < ActiveRecord::Base
# Tire setup
# ...
end
We can delete a Ticket instance, if we know its ID
document_id = ticket.id
Ticket.index.remove(Ticket.document_type, document_id)
Quite handy, if a model is deleted, but a corresponding delete didn't happen in ElasticSearch (the backgrounded index updater failed due to network failure etc.)
Written by Nisanth
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#