From 37e6b8d4dec0cda293d4aec18b02895207729022 Mon Sep 17 00:00:00 2001 From: jlonge4 <91354480+jlonge4@users.noreply.github.com> Date: Thu, 9 May 2024 05:52:41 -0400 Subject: [PATCH] Fixes deepset-ai/haystack-core-integrations#726 (#229) * keyword retrieval example * keyword retrieval example * keyword retrieval example * more explanation --------- Co-authored-by: Stefano Fiorucci --- integrations/pgvector-documentstore.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/integrations/pgvector-documentstore.md b/integrations/pgvector-documentstore.md index f36b6a2c..ace37530 100644 --- a/integrations/pgvector-documentstore.md +++ b/integrations/pgvector-documentstore.md @@ -84,7 +84,7 @@ indexing.run({"converter": {"sources": file_paths}}) ``` ### Retrieval from PgvectorDocumentStore -You can retrieve Documents similar to a given query using a simple Pipeline. +You can retrieve semantically similar documents to a given query using a simple pipeline that includes the `PgvectorEmbeddingRetriever`. ```python from haystack.components.embedders import SentenceTransformersTextEmbedder @@ -99,6 +99,15 @@ querying.connect("embedder", "retriever") results = querying.run({"embedder": {"text": "my query"}}) ``` +You can also retrieve Documents based on keyword matching with the `PgvectorKeywordRetriever`. + +```python +from haystack_integrations.components.retrievers.pgvector import PgvectorKeywordRetriever + +retriever = PgvectorKeywordRetriever(document_store=document_store, top_k=3)) +results = retriever.run(query="my query") +``` + ## Examples You can find a code example showing how to use the Document Store and the Retriever under the `examples/` folder of [this repo](https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/pgvector).