Following is the code screen shot
values of variables are
From debugging values are Constants.NESTED_CATEGORY_ITEMIDS is { $arrayElemAt: [{ $arrayElemAt: [{ $arrayElemAt: ['$categories.subCategories.subCategories.itemIds',2]},2]},0]} Constants.NESTED_CATEGORY_LEVEL is categories.2.subCategories.2.subCategories.0.itemIds Constants.NESTED_CATEGORY_VALUE is categories.subCategories.subCategories.subCategoryName menuId is 5e597a2be08a070bab329ef3 categoryName is Fish Taco From debugging aggregation value is { "aggregate" : "__collection__", "pipeline" : [{ "$match" : { "_id" : { "$oid" : "5e597a2be08a070bab329ef3" }, "categories.subCategories.subCategories.subCategoryName" : "Fish Taco" } }, { "$project" : { "subCategories.subCategories.itemIds',2]},2]},0]}}]}" : "$categories.subCategories.subCategories.itemIds',2]},2]},0]}}]}" } }] }
after running mongotemplate aggregate with following payload
I am getting following error
Please help me in writing projections to get the Constants.NESTED_CATEGORY_ITEMIDS