diff --git a/pkg/yqlib/doc/operators/headers/multiply-merge.md b/pkg/yqlib/doc/operators/headers/multiply-merge.md index 5ae05279..26e0a57b 100644 --- a/pkg/yqlib/doc/operators/headers/multiply-merge.md +++ b/pkg/yqlib/doc/operators/headers/multiply-merge.md @@ -28,3 +28,9 @@ Note the use of `eval-all` to ensure all documents are loaded into memory. ```bash yq eval-all '. as $item ireduce ({}; . * $item )' *.yml ``` + +# Merging complex arrays together by a key field +By default - `yq` merge is naive. It merges maps when they match the key name, and arrays are merged either by appending them together, or merging the entries by their position in the array. + +For more complex array merging (e.g. merging items that match on a certain key) please see the example [here](https://mikefarah.gitbook.io/yq/operators/multiply-merge#merge-arrays-of-objects-together-matching-on-a-key) + diff --git a/pkg/yqlib/doc/operators/multiply-merge.md b/pkg/yqlib/doc/operators/multiply-merge.md index f2a3fb52..9f04daed 100644 --- a/pkg/yqlib/doc/operators/multiply-merge.md +++ b/pkg/yqlib/doc/operators/multiply-merge.md @@ -29,6 +29,12 @@ Note the use of `eval-all` to ensure all documents are loaded into memory. yq eval-all '. as $item ireduce ({}; . * $item )' *.yml ``` +# Merging complex arrays together by a key field +By default - `yq` merge is naive. It merges maps when they match the key name, and arrays are merged either by appending them together, or merging the entries by their position in the array. + +For more complex array merging (e.g. merging items that match on a certain key) please see the example [here](https://mikefarah.gitbook.io/yq/operators/multiply-merge#merge-arrays-of-objects-together-matching-on-a-key) + + {% hint style="warning" %} Note that versions prior to 4.18 require the 'eval/e' command to be specified.