Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

DocumentWriter

Write documents to a document store.

Key Features

  • Writes a list of Document objects to any compatible DocumentStore.
  • Configures duplicate handling policies: skip, fail, overwrite, or upsert duplicates.
  • Returns the count of documents written to the store.
  • Used at the end of indexing pipelines to persist processed documents.

Configuration

  1. Drag the DocumentWriter component onto the canvas from the Component Library.
  2. Click the component to open the configuration panel.
  3. On the General tab:
    1. Configure the document_store with the target document store instance.
  4. Go to the Advanced tab to configure the duplicate handling policy (SKIP, FAIL, OVERWRITE, UPSERT, or INCREMENTAL).

Connections

DocumentWriter accepts a list of Document objects (documents) and an optional policy as input. It outputs documents_written, an integer representing the number of documents written.

Typically, DocumentWriter is the last component in an indexing pipeline. Connect a preprocessor or document joiner to the documents input to provide the final processed documents.

Usage Example

components:
DocumentWriter:
type: components.writers.document_writer.DocumentWriter
init_parameters:

Parameters

Inputs

ParameterTypeDefaultDescription
documentsList[Document]A list of documents to write to the document store.
policyOptional[DuplicatePolicy]NoneThe policy to use when encountering duplicate documents.

Outputs

ParameterTypeDefaultDescription
documents_writtenintNumber of documents written to the document store.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
document_storeDocumentStoreThe instance of the document store where you want to store your documents.
policyDuplicatePolicyDuplicatePolicy.NONEThe policy to apply when a Document with the same ID already exists in the DocumentStore. - DuplicatePolicy.NONE: Default policy, relies on the DocumentStore settings. - DuplicatePolicy.SKIP: Skips documents with the same ID and doesn't write them to the DocumentStore. - DuplicatePolicy.OVERWRITE: Overwrites documents with the same ID. - DuplicatePolicy.FAIL: Raises an error if a Document with the same ID is already in the DocumentStore.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
documentsList[Document]A list of documents to write to the document store.
policyOptional[DuplicatePolicy]NoneThe policy to use when encountering duplicate documents.