When importing my a json file using mongoimport, arrays are overwritten due to the field name for the actual array being the same, regardless of the elements in the array containing different data.
Is there a way to essentially combine and merge the arrays, instead of overwriting the array, when importing with mongoimport?
Although mongoimport can merge documents based on a list of fields into your collection it cannot perform complex transformation like concatenating arrays:
What I would suggest is to load the documents into a temporary stage collection and perform a post command/script doing a $merge aggregation with $zip of the source and target arrays.
Hi @James_Anderson, although mongoimport can’t do this currently, I think this is a pretty good suggestion. I made a feature request for this on Jira: TOOLS-2765. The feature might not get added very fast - we have a large backlog - but you can follow that ticket to be notified of updates.