【发布时间】:2019-06-30 14:05:32
【问题描述】:
我有一个这样定义的猫鼬模型。
const custSchema = new mongoose.Schema({
name: {
type: String,
es_indexed: true,
es_type: text
},
phoneNumber: {
type: String,
es_indexed: true,
es_type: String
},
email: String
})
custSchema.plugin(mongoosastic);
const Cust = module.exports = mongoose.model('Cust', custSchema);
Cust.createMapping(function(err, mapping) {
if(err) {
console.log(err)
} else {
console.log(mapping);
}
});
let count = 0;
const stream = Cust.synchronize();
stream.on('data', () => {
count = count + 1;
})
stream.on('close', () => {
console.log("Total " + count + " documents indexed");
})
stream.on('error', (err) => {
console.log(err)
});
当我将新集合添加到 Cust 时,除非我重新启动服务器,否则新文档不会添加到 elasticsearch。
我该如何解决这个问题?
【问题讨论】:
-
请发布您的索引设置。刷新时间改了吗?
-
不行,在哪里可以找到 index_setting 文件?
标签: node.js elasticsearch mongoose mongoosastic