Skip to main content

ListJoiner

Join multiple lists into a single flat list.

Basic Information

  • Type: haystack.components.joiners.list_joiner.ListJoiner
  • Components it can connect with:
    • Any component that outputs lists, such as generators that output List[ChatMessage] or other list-producing components.

Inputs

ParameterTypeDefaultDescription
valuesVariadic[List[Any]]The lists to be joined.

Outputs

ParameterTypeDefaultDescription

Overview

ListJoiner receives multiple lists of the same type and concatenates them into a single flat list. The output order respects the pipeline's execution sequence, with earlier inputs being added first.

This component is useful when you need to combine list outputs from multiple components, such as:

  • Joining documents from multiple file converters in an indexing pipeline
  • Collecting chat messages from different stages of a conversation
  • Merging LLM responses from parallel processing

Usage Example

This example shows an index that converts different file types (text, markdown, PDF) and joins all documents into a single list for processing.

components:
TextFileToDocument:
type: haystack.components.converters.txt.TextFileToDocument
init_parameters:
encoding: utf-8
store_full_path: false
MarkdownToDocument:
type: haystack.components.converters.markdown.MarkdownToDocument
init_parameters:
store_full_path: false
PDFMinerToDocument:
type: haystack.components.converters.pdfminer.PDFMinerToDocument
init_parameters:
store_full_path: false
ListJoiner:
type: haystack.components.joiners.list_joiner.ListJoiner
init_parameters:
list_type_: list[haystack.dataclasses.document.Document]
DocumentSplitter:
type: haystack.components.preprocessors.document_splitter.DocumentSplitter
init_parameters:
split_by: sentence
split_length: 100
split_overlap: 0
split_threshold: 0
splitting_function:
DocumentWriter:
type: haystack.components.writers.document_writer.DocumentWriter
init_parameters:
policy: OVERWRITE
document_store:
type: haystack.document_stores.in_memory.document_store.InMemoryDocumentStore
init_parameters:
bm25_tokenization_regex: (?u)\b\w\w+\b
bm25_algorithm: BM25L
bm25_parameters:
embedding_similarity_function: dot_product
index: 'default'
async_executor:
return_embedding: true

FileTypeRouter:
type: haystack.components.routers.file_type_router.FileTypeRouter
init_parameters:
mime_types:
- application/pdf
- text/markdown
- text/plain
additional_mimetypes:
raise_on_failure: false

connections:
- sender: TextFileToDocument.documents
receiver: ListJoiner.values
- sender: MarkdownToDocument.documents
receiver: ListJoiner.values
- sender: PDFMinerToDocument.documents
receiver: ListJoiner.values
- sender: ListJoiner.values
receiver: DocumentSplitter.documents
- sender: DocumentSplitter.documents
receiver: DocumentWriter.documents

- sender: FileTypeRouter.application/pdf
receiver: PDFMinerToDocument.sources
- sender: FileTypeRouter.text/markdown
receiver: MarkdownToDocument.sources
- sender: FileTypeRouter.text/plain
receiver: TextFileToDocument.sources

max_runs_per_component: 100

metadata: {}

inputs:
files:
- FileTypeRouter.sources


Parameters

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
list_type_Optional[Type]NoneThe expected type of the lists this component will join (e.g., List[ChatMessage]). If specified, all input lists must conform to this type. If None, the component defaults to handling lists of any type including mixed types.

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
valuesVariadic[List[Any]]The list to be joined.