diff --git a/haystack/components/joiners/document_joiner.py b/haystack/components/joiners/document_joiner.py index b81af3cde0..103ab1c574 100644 --- a/haystack/components/joiners/document_joiner.py +++ b/haystack/components/joiners/document_joiner.py @@ -54,7 +54,20 @@ class DocumentJoiner: ### Usage example: ```python + from haystack import Pipeline, Document + from haystack.components.embedders import SentenceTransformersTextEmbedder, SentenceTransformersDocumentEmbedder + from haystack.components.joiners import DocumentJoiner + from haystack.components.retrievers import InMemoryBM25Retriever + from haystack.components.retrievers import InMemoryEmbeddingRetriever + from haystack.document_stores.in_memory import InMemoryDocumentStore + document_store = InMemoryDocumentStore() + docs = [Document(content="Paris"), Document(content="Berlin"), Document(content="London")] + embedder = SentenceTransformersDocumentEmbedder(model="sentence-transformers/all-MiniLM-L6-v2") + embedder.warm_up() + docs_embeddings = embedder.run(docs) + document_store.write_documents(docs_embeddings['documents']) + p = Pipeline() p.add_component(instance=InMemoryBM25Retriever(document_store=document_store), name="bm25_retriever") p.add_component( @@ -67,7 +80,7 @@ class DocumentJoiner: p.connect("embedding_retriever", "joiner") p.connect("text_embedder", "embedding_retriever") query = "What is the capital of France?" - p.run(data={"query": query}) + p.run(data={"query": query, "text": query, "top_k": 1}) ``` """