Forum Discussion
you can use the match operator to match the each doc in the array and map it to whatever you’d like
so using this expression:
$Subarray.map(entry => match entry { {SubProperty1, SubProperty2} => {"SubProp1": SubProperty1, "SubProp2": SubProperty2}, _ => []})
mapped to MyArray
should give you the desired output for the nested array portion. The rest seems to just be direct mappings from source Property1
to target Prop1
, Property2
to target Prop2
while setting pass through to off.
One thing to note, the ‘_’ is used as a default incase there is a document that does not match any of the arms in the match. So, if there is a doc that does not have these fields it would default to an empty array, which you can change.
Thank you, this solutions seems to work!
Related Content
- 3 months ago
- 10 months ago
- 3 years ago