Mongo Playground

Configuration

[{"productId":1,"isVariant":1,"isComplete":1,"variantId":1,"attributeSet":[{"name":"Capacity","value":"500 GB","id":3},{"name":"Form Factor","value":"5 inch","id":4},{"id":5,"name":"Memory Components","value":"3D NAND","isVariation":0}]},{"productId":2,"isVariant":1,"isComplete":1,"variantId":1,"attributeSet":[{"name":"Capacity","value":"1 TB","id":3},{"name":"Form Factor","value":"5 inch","id":4},{"id":5,"name":"Memory Components","value":"3D NAND","isVariation":0}]},{"productId":3,"isVariant":1,"isComplete":0,"variantId":1,"attributeSet":[{"name":"Capacity","value":"500 GB","id":3},{"name":"Form Factor","value":"2.5 inch","id":4},{"id":5,"name":"Memory Components","value":"3D NAND","isVariation":0}]},{"productId":4,"isVariant":1,"isComplete":0,"variantId":1,"attributeSet":[{"name":"Capacity","value":"1 TB","id":3},{"name":"Form Factor","value":"2.5 inch","id":4},{"id":5,"name":"Memory Components","value":"3D NAND","isVariation":0}]}]

Query

db.collection.aggregate([{$match:{isComplete:1}},{$project:{_id:0,attributeSet:1}},{$unwind:"$attributeSet"},{$match:{"attributeSet.isVariation":{$ne:0}}},{$group:{_id:"$attributeSet.id",name:{$first:"$attributeSet.name"},value:{$addToSet:"$attributeSet.value"}}}])

Result