目前我正在使用mongoose Model.remove方法来删除文档。但是在删除文档后,mongoosastic索引仍然包含删除的文档索引。
User.remove({_id:userId}, function(err) {
if (err) {
res.json({success:false});
}
else {
res.json({success:true})
}
});发布于 2016-11-01 15:37:22
基于mongoosastic documentation中的这一部分
请注意,Model.remove的使用不涉及文档中概述的mongoose文档。因此,以下代码不会取消对文档的索引。
User.remove({_id: userId})不会触发mongoosastic unindex。
相反,您可以轻松地找到用户并对其调用.remove()。下面是它的外观:
User.findById(userId, function(error, user) {
user.remove(function(err) {
if (err) {
res.json({success:false});
}
else {
res.json({success:true})
}
});
});发布于 2019-02-13 15:46:37
这在2019年仍然是一个悬而未决的问题,只需使用HTTP调用直接删除即可。
我使用ff
await fetch('http://localhost:9200/put_index_here/put_type_here/doc_id_here', { method: 'DELETE', body:'' });https://stackoverflow.com/questions/35621262
复制相似问题