Why is mongoosastic populate / elastic search not populating one of my references? I'm getting an empty object
I've got it working, but it differs much from the examples given on npm / github.
I had to remove the es_schema: Style, (as I had accidentally done for brand, which was why it worked). I had to add the es_type: "nested" / es_include_in_parent, which I gathered from elasticsearch and mongoosastic documentation.
I'm not sure this is intended, but it seems to work:
style: {type: mongoose.Schema.Types.ObjectId, ref: 'Style', es_type:'nested', es_include_in_parent:true},
I now get : style: [Object] as needed, when I console.log results.hits .
Below is the example given in npm , which did not work for me:
var Comment = new Schema({ title: String , body: String , author: String});var User = new Schema({ name: {type:String, es_indexed:true} , email: String , city: String , comments: {type: Schema.Types.ObjectId, ref: 'Comment', es_schema: Comment, es_indexed:true, es_select: 'title body'}})User.plugin(mongoosastic, { populate: [ {path: 'comments', select: 'title body'} ]})