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

DocumentJoiner

Use DocumentJoiner to merge multiple lists of documents from different pipeline branches into a single list. While most pipelines can use smart connections to automatically merge document lists, DocumentJoiner provides explicit control over the joining process.


Key Features

  • Merges multiple document lists into a single output
  • Maintains document order from input lists
  • Supports any number of input connections

When To Use DocumentJoiner

Use DocumentJoiner when:

  • You need explicit control over how document lists are merged
  • Your pipeline has complex branching that requires specific joining logic

In most cases, you can simplify your pipeline by using smart connections instead. Components automatically accept multiple lists of the same type and merge them. For more information, see Smart Connections.

Configuration

DocumentJoiner requires no initialization parameters. Simply connect multiple components that output document lists to its inputs.

Connections

Compatible input types: Any component that outputs List[Document]

Output type: List[Document]

Common input components:

  • Retrievers
  • Document processors
  • Other DocumentJoiner components

Common output components:

  • Rankers
  • Generators
  • Document writers

Usage Example

components:
bm25_retriever:
type: haystack.components.retrievers.in_memory.InMemoryBM25Retriever
params:
document_store:
type: haystack.document_stores.in_memory.InMemoryDocumentStore

embedding_retriever:
type: haystack.components.retrievers.in_memory.InMemoryEmbeddingRetriever
params:
document_store:
type: haystack.document_stores.in_memory.InMemoryDocumentStore

document_joiner:
type: haystack.components.joiners.document_joiner.DocumentJoiner

ranker:
type: haystack.components.rankers.transformers_similarity.TransformersSimilarityRanker

connections:
- sender: bm25_retriever.documents
receiver: document_joiner.documents
- sender: embedding_retriever.documents
receiver: document_joiner.documents
- sender: document_joiner.documents
receiver: ranker.documents

Parameters

Inputs

ParameterTypeDescription
documentsList[Document]Lists of documents to join together. Accepts multiple connections.

Outputs

ParameterTypeDescription
documentsList[Document]The combined list of all input documents.

Init Parameters

DocumentJoiner has no initialization parameters.

Run Method Parameters

DocumentJoiner has no run-time parameters.