Skip to content

Mapping between collections and non-collections

In the Data Mapper Source and Target panels:

  • A collection is one or more fields that may appear multiple times in a document.
  • If the collection contains one primitive type, you can map directly from or to that collection. If the collection contains two or more different types, the Data Mapper displays the collection’s child fields and you can map to or from the collection’s fields.
  • A complex type contains multiple fields of different types. A field in a complex type can be a type that is a collection, such as an array. You cannot map a complex type container itself. You can map only the fields that are in the complex type.

Collection field to Non-Collection Field Mapping – Many to one Mapping

When you map from a collection field to a non-collection field, you can choose to either concatenate the values of the repeating field or specify a specific field to map.

When you create the mapping, the default action is set to Concatenate. This maps the values in all fields of the source collection. The default delimiter that is added between the source field values is a space.

To map from a specific field in the collection, select the Item At Action and specify the zero-based index for which repeating field to map. For example, to map the value that is in the first field that is in the collection, specify 0 for the index:

Note – Test preview doesn’t support Collection to Non-collection mapping

Non-Collection Field to Collection Field Mapping – One to Many Mapping

When you map from a non-collection field to a collection field, you can choose to split the value of the source field into multiple fields in the target collection, copy the entire value of the source field into a specific field in the target collection or copy the entire value of the source field into multiple fields of the target collection.

When you create the mapping, the default action is set to Split. This splits the value of the source field into multiple fields of the target collection. The default separator that is that is used to determine how to split the value of the source field is a space. For example, consider a non-collection, source cities field that contains: Boston Paris Tokyo. If you mapped this to a field that is in a collection with the Split action, the Data Mapper splits the value of the cities field at the space delimiter. The result is three instances of the collection. In the first instance, the value of the city field is Boston. In the second instance, the value of the city field is Paris. In the third instance, the value of the city field is Tokyo.

To map the entire value of the source field into a specific instance of a target collection, select the Copy To Action and specify the zero-based index to map the value into. The Copy To action is applied using the following rules:

  1. If the target collection is empty, the Data Mapper will add the number of empty instances to the collection equal to the index + 1 and insert the value of the source field into the last instance of the collection.
  2. If the target collection already has the number of instances equal to or less than the index + 1, the value of the source field is copied into the instance of the target collection as defined by the zero-based index value.
  3. If the target collection already has one or more instances, but the value of the index is greater than the number of instances in the target collection, the Data Mapper will add the number of empty instances up to the index + 1 and insert the value of the source field into the last instance of the collection.

For example, to map the value that is to the first instance of the target collection, specify 0 for the index:

To map the entire value of the source field into a set number of instances of a target collection, select the Repeat Action and specify the number of instances to map the value into. The Repeat Action is applied using the following rules:

  1. If the target collection is empty, then the number of instances specified by the count’s value are created.
  2. If the target collection already has one or more instances, but greater than the count’s value, the value of the source field is copied into the number of instances of the target collection as defined by the count’s value. For example, if count is two and there are three instances of the collection, then the source field’s value is only copied into the first two instances of the collection.
  3. If the target collection already has one or more instances, but less than the count’s value, the value of the source field is copied into all of the instances of the target collection, and will create additional instances of the target collection up to the value of count.

Collection Field to Collection Field Mapping – For Each mapping

When you map from a collection field to another collection field, the default behavior is that for each source collection instance, one target instance collection is created. This is useful for mapping repeating items from a source to target document, like items or addresses:

Was this article helpful?
Dislike 0
Previous: Transforming source or target data
Next: Separating one source field into multiple target fields