Return 3 nested documents per category

(Robert Simon) #1


We have this document structure in mongo

masterProduct_id: String
category: String
variants: [
  variantGroup_id: String
  priority: Number
  accessories: [
    masterProduct_id: String
    variantGroup_id: String

I need to query accessories for 1 product variant to be shown on page.
Relations between accessories are on variants level, so identified by masterProduct_id and variantGroup_id pair.
Result should be represented by array of categories and in every category top 3 variants based on "priority".

Currently we are syncing it to ES using transporter, so no nested indexes created by default.
I am trying to reach my goal step by step and studying documentation atm.

(system) #2