How to index deleted rows in act_as_paranoid rows in sunspot

I am using sunspot and act_as_paranoid gems in ruby ​​on a rails application.

When I delete an entry, the act_as_paranoid gem overrides the ActiveRecord behavior, but does not delete it, but updates the deleted_at field to a non-zero value. And by default add all AR queries WHERE deleted_at IS NULL scipe.

I have many remote users. And on the adminpanel page, I need to browse and search.

The problem is that when overriding the User model, sunspot does not index remote users at all (adding the WHERE deleted_at IS NULL by default).

The only chance to index it is to run it manually.

 User.with_deleted.solr_reindex 

So the question is: how should I change my code so that the spot ALWAYS indexes deleted entries in the User model?

 class User < ActiveRecord::Base searchable do string :class_name do self.class.name end integer(:model_id) { |user| user.id } integer :community_ids, references: 'Community', multiple: true # ... end # ... end 
+5
source share

All Articles