Skip to content

Commit

Permalink
initial import (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsbatista authored Feb 14, 2024
1 parent ae42a2e commit 9192266
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions integrations/pgvector-documentstore.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ toc: true
- [License](#license)

## Installation
pgvector is an extension for PostgreSQL that adds support for vector similarity search.
`pgvector` is an extension for PostgreSQL that adds support for vector similarity search.

To quickly setup a PostgreSQL database with pgvector, you can use Docker:
To quickly set up a PostgreSQL database with pgvector, you can use Docker:
```bash
docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres ankane/pgvector
```
Expand All @@ -45,13 +45,18 @@ Use `pip` to install `pgvector-haystack`:
pip install pgvector-haystack
```
## Usage

Define the connection string to your PostgreSQL database in the `PG_CONN_STR` environment variable. For example:
```bash
export PG_CONN_STR="postgresql://postgres:postgres@localhost:5432/postgres"
````

Once installed, initialize PgvectorDocumentStore:

```python
from haystack_integrations.document_stores.pgvector import PgvectorDocumentStore
document_store = PgvectorDocumentStore(
connection_string="postgresql://postgres:postgres@localhost:5432/postgres",
table_name="haystack_docs",
embedding_dimension=768,
vector_function="cosine_similarity",
Expand All @@ -64,6 +69,7 @@ document_store = PgvectorDocumentStore(
To write documents to `PgvectorDocumentStore`, create an indexing Pipeline.

```python
from haystack import Pipeline
from haystack.components.converters import TextFileToDocument
from haystack.components.writers import DocumentWriter
from haystack.components.embedders import SentenceTransformersDocumentEmbedder
Expand Down

0 comments on commit 9192266

Please sign in to comment.