我有两个模型,我试图参考.风格和品牌.
Brand填充了所需的对象,但Style始终为空.
我已经尝试清除缓存/删除索引.有和没有include_in_parent和类型:'嵌套'.
我觉得它可能与指定的es_type等有关.不确定.
产品架构:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Style = require('./style');
var Brand = require('./brand');
var mongoosastic = require('mongoosastic');
var ProductSchema = new mongoose.Schema({
name: { type: String, lowercase: true , required: true},
brand: {type: mongoose.Schema.Types.ObjectId, ref: 'Brand',
es_type:'nested', es_include_in_parent:true},
style: {type: mongoose.Schema.Types.ObjectId, ref: 'Style',
es_schema: Style, es_type:'nested', es_include_in_parent: true},
year: { type: Number }
});
ProductSchema.plugin(mongoosastic, {
hosts: [
'localhost:9200'
],
populate: [
{path: 'style'},
{path: 'brand'}
]
});
Product = module.exports = …Run Code Online (Sandbox Code Playgroud)