embedded式Mongoose的弹性search

我有以下mongoose模式:

var ReviewSchema = new Schema({ title: String, details: String, user: {type: ObjectId, ref:'User'}, }); var SubjectSchema = new Schema({ name: {type: String, required: true}, website: {type: String, index: { unique: true }}, review: {type: [ReviewSchema], es_indexed:true} }); 

我有另一个User纲要,在Review引用。

我试过mongoosastic插件,但我无法find方法索引引用的架构。 我想索引评论用户的名字。 所以我只是用这个弹性search客户端。

每创build/更新/删除评论,我都在数据库中查找,并用从数据库中取回的值更新弹性search索引。 在更新embedded式模式时是否有更好的方法来更新索引? 谢谢

这可以使用mongoosastic来完成,有一个选项可以像Mongoosemongoosastic中填充,使用它可以索引mongoose参考。

 ReviewSchema.plugin(mongoosastic, { populate: [ {path: 'User', select: 'name'} ] }) 

你可以在这里的文档中find更多关于这方面的信息。