$split

Reference type:Cheat sheetFormat:Syntax + example + use case

Reference group: String aggregation expressions

What it does

Splits a string into an array at a delimiter.

Syntax

{$split: [string, delimiter]}

Use case

Parse simple delimited fields.

Important notes

Not a full CSV parser.

$split: practical example
{ $project: { parts: { $split: ["$path", "/"] } } }
💡 Explanation Splits a string into an array at a delimiter. When to use it Parse simple delimited fields. Caution Not a full CSV parser.
Key Takeaways
  • Splits a string into an array at a delimiter.
  • Typical use: Parse simple delimited fields.