Haystack docs home page

Join Documents

This Node receives Documents from multiple Nodes and joins them back together. This allows for the merging of two separate Pipeline branches.

Position in a PipelineGenerally used in cases where two separate branches have two different Retrievers whose results need to be amalgamated
InputDocuments
OutputDocuments
ClassesJoinDocuments

Usage

To use JoinDocuments in a Pipeline, run the following. Here the outputs of the ESRetriever and the DPRRetriever are combined by JoinDocuments.

from haystack.nodes import Pipeline
from haystack.nodes import JoinDocuments, QueryClassifier
join_documents = JoinDocuments(
join_mode="concatenate",
top_k_join=10
)
pipe = Pipeline()
pipe.add_node(component=QueryClassifier(), name="QueryClassifier", inputs=["Query"])
pipe.add_node(component=es_retriever, name="ESRetriever", inputs=["QueryClassifier.output_1"])
pipe.add_node(component=dpr_retriever, name="DPRRetriever", inputs=["QueryClassifier.output_2"])
pipe.add_node(component=join_documents, name="JoinResults",
inputs=["ESRetriever", "DPRRetriever"])
res = pipe.run(query="What did Einstein work on?")