我在 MEAN 堆栈程序中有 mongoosastic 设置。一切正常,除了当我从 mongodb 中删除一个文档时,它没有在弹性搜索索引中删除。因此,每次我进行包含删除项目的搜索时,都会返回已删除的项目,但在水合时为空。mongoosastic 是否处理从 ES 索引中删除?我必须对索引刷新进行编程吗?
var mongoose = require('mongoose');
var mongoosastic = require("mongoosastic");
var Schema = mongoose.Schema;
var quantumSchema = new mongoose.Schema({
note: {
type: String,
require: true,
es_indexed: true
}
});
quantumSchema.plugin(mongoosastic);
var Quantum = mongoose.model('Quantum', quantumSchema);
Quantum.createMapping(function(err, mapping){
if(err){
console.log('error creating mapping (you can safely ignore this)');
console.log(err);
}else{
console.log('mapping created!');
console.log(mapping);
}
});