Delete / delete indexed document in ElasticSearch using Tire (with soft deletion via ActsAsParanoid)

I have an ElasticSearch server that runs these indexes and searches for documents using the excellent Tire stone. Everything works fine, but I'm not sure how to manually remove documents from the search index.

I poured RDoc and looked for a watch, but this is the only hint of a solution that I can find https://github.com/karmi/tire/issues/309 . Is there an easier way besides creating a custom wrapper around the curl and executing the request manually?

Another problem is that I am using a soft-delete pearl called ActsAsParanoid, so Tire :: Model :: Callbacks does not delete the object on soft-delete.

Any ideas?

+6
source share
2 answers

If you only have an 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)

link

+10
source

Turns out you can just delete the deleted object with the standard index like this:

 @user = User.find(id) #or whatever your indexed object is User.tire.index.remove @user #this will remove them from the index 

Here it is!

+6
source

Source: https://habr.com/ru/post/927264/


All Articles