Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoosastic index data not getting deleted after removing document

Currently i am using mongoose Model.remove method to remove a document. But after removing document mongoosastic index still contains deleted document index.

User.remove({_id:userId}, function(err) {    
   if (err) {       
      res.json({success:false});    
   }
   else {
      res.json({success:true}) 
   } 
});
like image 983
Atharva Dandekar Avatar asked Feb 04 '26 14:02

Atharva Dandekar


1 Answers

This is caused because mongoose calls the delete index hook only when you do a user.remove() instead of User.remove({_id: userId}), for that reason mongoosastic could not delete this document.

You can see that in mongoostatic docs about removing documents:

https://github.com/mongoosastic/mongoosastic#removing-a-document

like image 118
Rodrigo Lopetegui Avatar answered Feb 07 '26 07:02

Rodrigo Lopetegui



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!