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

load

Last update:
May 18, 2026
Loads documents from the file system or a URL and returns them as an Array of document Structs. Supports directory traversal, parallel loading, pattern filtering, custom parsers, and HTTP request options for URL sources.

Syntax

docService.load(config)

Parameters

The config argument is a Struct with the following keys:
Key
Type
Default
Description
path
String
Required. File path, directory path, or URL to load documents from.
recursive
Boolean
false
When loading from a directory, recursively traverses subdirectories.
parallel
Boolean
false
Enables parallel document loading for filesystem sources.
maxThreads
Numeric
4
Maximum number of parallel worker threads used when parallel = true.
includePatterns
Array of String
Glob patterns for files to include (for example, ["*.txt"]).
excludePatterns
Array of String
Glob patterns for files to exclude (for example, ["*draft*"]).
pattern
String
Legacy glob pattern for file selection (for example, "*.{pdf,txt}").
charset
String
"UTF-8"
Character encoding used for text-based formats.
parserType
String
Auto-detected
Explicit parser to use instead of auto-detection.
parserConfigs
Struct
{}
Per-parser configuration overrides. Supported sub-keys: csv (rowPerDocument, contentColumns, metadataColumns), json (jsonPath, contentKey), xml (includeAttributes), properties (sortKeys).
maxFileSize
Numeric (bytes)
100 MB
Maximum allowed file size. Files exceeding this limit are skipped.
requestOptions
Struct
{}
HTTP request options used when loading from a URL. Keys: headers (Struct), connectionTimeout (ms), readTimeout (ms), maxRetries (Numeric), userAgent (String).

Returns

Returns an Array of document structs. Each struct contains:
  • text (String): Extracted document text.
  • metadata (Struct): Contains source, fileName, fileSize, mimeType.

Examples

Example 1: Basic filesystem load
docs = docService.load({
    path:      "./manuals/",
    recursive: true,
    pattern:   "*.pdf"
});
writeOutput("Loaded #arrayLen(docs)# documents");
Example 2 : Parallel load with custom parser configs
docs = docService.load({
    path:            dir,
    recursive:       true,
    parallel:        true,
    maxThreads:      4,
    includePatterns: ["*.txt"],
    excludePatterns: ["*draft*"],
    charset:         "UTF-8",
    parserConfigs: {
        csv: {
            rowPerDocument:  true,
            contentColumns:  ["name", "description"],
            metadataColumns: ["id", "category"]
        },
        json: {
            jsonPath:   "$.articles[*]",
            contentKey: "body"
        }
    }
});
Example 3: URL load with custom headers
docs = docService.load({
    path: "https://example.com/data.txt",
    requestOptions: {
        headers: {
            "Authorization": "Bearer #token#"
        },
        connectionTimeout: 60000,
        readTimeout:       120000,
        maxRetries:        2,
        userAgent:         "ColdFusion-RAG/1.0"
    }
});

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