我使用ElasticSearch和mongoosastic到的MongoDB和ElasticSearch.I之間同步數據要包括架構這是我的另一個研究對象的屬性:我想有要顯示的類別文章,我正在尋找。 這是我的2種模式:ArticleSchema和CategorySchema。文章包含一個名爲「Categorie」的類別對象。包含的ObjectId在搜索Elasticsearch
var ArticleSchema = new Schema({
created: {
type: Date,
default: Date.now
},
...
user: {
type: Schema.ObjectId,
ref: 'User'
},
categorie: {
type: Schema.ObjectId,
es_indexed:true,
ref: 'Category',
required: 'Le champ "Categorie" ne peut pas etre vide'
}
});
var CategorySchema = new Schema({
name: {
type: String,
default: '',
required: 'Please fill Category name',
trim: true
},
...
niveau: {
type: Number
}
});
是否有引用由他們的ObjectId文件,而不是作爲一個子文件由模式創建它的另一種方式? IE瀏覽器。像貓鼬的參考和填充()? –
貌似不開箱。我去看看我可以通過水化添加功能,併爲它創建一個PR今晚。你的回答讓我更深入瞭解了這個問題,並認識到嵌套模型和人口之間的差異。謝謝! –