I have an ElasticSearch server running that indexes and searched documents using the excellent Tire gem. Everything works great, except I'm not sure how to go about manually removing documents from the search index.
I have poured over the RDoc and searched for hours, but this is the only hint at a solution I can find https://github.com/karmi/tire/issues/309. Is there an easier way other than building a custom wrapper around curl and making the request manually?
Another hitch is that I use a soft-delete gem called ActsAsParanoid, so the Tire::Model::Callbacks won't remove the object on soft-delete.
Any ideas?
In case you only have the ID (e.g. 12345):
User.tire.index.remove 'user', '12345'
Or more generally:
klass.tire.index.remove klass.document_type, record_id
(which I think is equivalent to what remove @user
will do behind the scenes)
reference
Turns out you can just manually remove the soft-deleted Object from the index like so:
@user = User.find(id) #or whatever your indexed object is
User.tire.index.remove @user #this will remove them from the index
Thats it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With