Adjust Chunk Size
When processing large documents, you might need to adjust how much text is included in each chunk. By default, chunks are 1024 characters long, but you can customize this size to better match your content and memory requirements. This example shows how to set a custom chunk size when splitting documents.
import { MDocument } from "@mastra/rag";
const doc = MDocument.fromText("Your plain text content...");
const chunks = await doc.chunk({
size: 512,
});
View Example on GitHub