data:document:extract
Walks a parsed document by segment pattern and emits keyed items. It reads the flat item list a document parse produces, keeps the items whose path matches the pattern, names the captured segments, and emits one output item per match. Repeated matches collapse into one item when group fields are configured, which is how plurals and arrays come back out of a document as a single entry.
Options
| Name | Type | Description |
|---|---|---|
items | []map[string]any | The parsed document items to walk, usually document selections |
match | ExtractMatch | The segment pattern deciding which items are extracted |
↳ path | string | The item field holding the segments to match, as a dotted path |
↳ pattern | []string | The segment pattern an item must match to be extracted |
↳ exclude_patterns | []string | Segment patterns that drop an otherwise matching item |
fields | any | The output fields, each named and read from a path, a capture, or a literal |
group_by | []string | The output field names that collapse repeated items into one |
aggregates | any | The collections built from every item in a group |
limit | int | Caps the number of emitted items, zero for all of them |
Outputs
| Name | Type | Description |
|---|---|---|
items | []map[string]any | The extracted items |
Example
name: Extract document entries
actions:
- name: entries
component: data:document:extract
vars:
items: "{{ var.selections }}"
match:
path: path
pattern: ["{key...}"]
exclude_patterns:
- ["{key...}", "{index#}"]
fields:
key:
capture: key
join: "."
value:
path: value
outputs:
items: "{{ entries.items }}"