对于我的单元测试,在做猫鼬模式的概述之前,我正在使用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');
});在我的邮政路线上,我的急救室是空的。我不知道为什么?另外,Model.esSearch是一个在库中不存在的函数,但是我正在认真考虑开始使用默认的esClient,这是文档中的https://github.com/mongoosastic/mongoosastic/issues/219。你对这个图书馆有什么经验?
发布于 2016-07-07 17:21:23
这可能很难找到,但在我的例子中,不是库,而是我的ES集群健康状态是红色的,因为我没有足够的磁盘空间。您可以尝试以下几种方法:
这是为了我..。
https://stackoverflow.com/questions/38244284
复制相似问题