Iterator: Group By
Bucket the elements of a list. The sub-graph runs once per element and emits
two values to the auto-created Iterator::Collect:
key(String) — the bucket label.value(any) — the element to put in that bucket. When omitted, the original element is used.
The result is a JSON object whose keys are the distinct bucket labels and
whose values are arrays of the matching elements. Elements whose sub-graph
yields a missing or non-String key are silently dropped (no error). Bucket
keys appear in alphabetical order in the output object, not in first-seen
order.
Example
Input: [{name: "alice", team: "A"}, {name: "bob", team: "B"}, {name: "carol", team: "A"}]
Body: key = el.team, value = el.name
Output:
{
"A": ["alice", "carol"],
"B": ["bob"]
}
Parameters
This function has no parameters.
Input
Arrayrequired
List to bucket (Array or JSON array).
Value
Optional value injected into every iteration as value on the entry node.
Output
Result
JSON object — one key per distinct bucket label, each holding an array of the matching values.