Whatever message this page gives is out now! Go check it out!

split

Last update:
May 18, 2026
Splits an Array of document Structs into smaller text segment Structs using the specified chunking strategy. The resulting segments are suitable for embedding and vector store ingestion.

Syntax

docService.split( documents [, options] )

Parameters

Parameter
Type
Required
Description
documents
Array
Required
Array of document Structs as returned by load().
options
Struct
Optional
Splitting configuration. Keys: splitterType (String, default "recursive": valid values: recursive, paragraph, sentence, line, character, word, regex); chunkSize (Numeric, default 1000); chunkOverlap (Numeric, default 100); separators (Array of String, for recursive splitter); regexPattern (String, required when splitterType = "regex").

Returns

Returns an Array of text segment Structs, each with: text (String) and metadata (Struct).

Example

segments = docService.split(documents, {
    splitterType: "recursive",
    chunkSize:    1000,
    chunkOverlap: 100
});
writeOutput("Created #arrayLen(segments)# segments");

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page