Importing Data#
Concourse supports importing data from JSON and CSV formats, both programmatically through the API and via command-line tools.
JSON Import#
The insert method is the primary way to import structured data
into Concourse. It accepts JSON strings containing objects or
arrays of objects.
Single Object#
1 2 3 4 5 | |
1 2 | |
Array of Objects#
Pass a JSON array to insert multiple records at once:
1 2 3 4 | |
JSON Structure#
JSON objects in the import data must follow these rules:
- Each key maps to a JSON primitive or an array of JSON primitives
- Nested objects are not supported
- Arrays of primitives create multi-valued fields
1 2 3 4 5 6 | |
The tags key in this example would contain two values:
"founder" and "engineer".
Resolvable Links#
JSON import data can include resolvable link instructions to
automatically create links to records matching a criteria. Use
the @criteria@ syntax:
1 2 3 4 | |
See Writing Data for details.
CSV Import#
Concourse provides a CLI tool for importing CSV files.
Basic Usage#
1 | |
The importer reads the CSV file, uses the first row as key names, and inserts each subsequent row as a new record.
Data Source Annotation#
Use the --annotate-data-source flag to automatically add a
field to each imported record indicating the source file:
1 | |
Import Options#
The CSV importer supports:
- Header detection: The first row is automatically treated as the header containing key names
- Type inference: Values are automatically typed (numbers, booleans, strings)
- Batch processing: Records are inserted in batches for performance
Map and Multimap Import#
The Java API supports importing data from Map and Multimap
objects:
Map Import#
1 2 3 4 5 | |
Multimap Import#
Use a Multimap when keys should have multiple values:
1 2 3 4 5 6 7 | |
Batch Import#
Import multiple maps at once:
1 2 3 4 5 6 | |
Import into Existing Records#
All insert methods support writing into specific existing records. The insert fails for a given record if any of the key/value associations already exist.
1 2 3 4 5 6 7 | |
Resolution#
When importing data, Concourse resolves each key/value pair by
attempting to add it to the target record. If the exact key/value
pair already exists in the record, the add is skipped (and the
insert fails for that record when using insert into existing
records). This ensures that imports are idempotent for new records
but enforce uniqueness when targeting existing records.