How do I do populate on mongoosastic? How do I do populate on mongoosastic? mongoose mongoose

How do I do populate on mongoosastic?


You are using

populate: [  {path: 'categories', select: 'name'}]

But categories in your code is undefined.

You have to use category in the place of categories as you have mentioned the key as category in the schema declaration

Hope it will solve your problem.


Edit:

category: { type: Schema.Types.ObjectId, ref: 'Category', es_schema: Category, es_indexed:true, es_select: 'name'},

=> _category : { type: Schema.Types.ObjectId, ref: 'Category' },

And use populate: .populate('_category ', 'name')

Hope it will help you.

See more: http://mongoosejs.com/docs/populate.html