2
为我的单元测试我在做我的猫鼬模式的bulkindex之前使用mongoosastic截断我的模型。mongoosastic没有索引保存的数据
架构:
model: {
name: {type: String, required: true, es_indexed: true, index: 'not_analyzed'},
aliases: {type: [String], es_indexed: true, index: 'not_analyzed'},
birth: {type: Date, es_type: 'date', es_indexed: true, index:
},
架构插件:
schema.plugin(mongoosastic, {
esClient,
index: model,
});
截断情形:
Model.esTruncate(function (err) {
if (err) {
console.error(err);
}
console.log("[ElasticSearch] Model removed")
Model.indexFiles();
});
重建索引:
Model.indexFiles = function() {
console.log('[ElasticSearch] Start indexing ' + entityName + ' documents');
var stream = model.synchronize();
var count = 0;
stream.on('data', function (err, doc) {
count++;
});
stream.on('close', function() {
console.log('[ElasticSearch] Indexed ' + count + ' ' + entityName + ' documents!');
});
stream.on('error', function (err) {
console.log('mongoosastic ERROR');
console.log(err);
});
};
但是我登录:
Model.on('es-indexed', function (err, res) {
console.log('model added to es index');
});
在我的邮路,我ES保持为空。 我不知道为什么? 此外,Model.esSearch是一个功能,它不存在库中,但它被记录在内https://github.com/mongoosastic/mongoosastic/issues/219 我认真考虑开始使用默认esClient。 你对这个图书馆有什么经验?