Skip to content

PGVectorStore

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:151

Provides support for writing and querying vector data in Postgres. Note: Can’t be used with data created using other Python vector store implementations

new PGVectorStore(config): PGVectorStore

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:164

PGVectorStoreConfig

PGVectorStore

BaseVectorStore.constructor

optional isEmbeddingQuery: boolean

Defined in: packages/core/src/vector-store/index.ts:120

BaseVectorStore.isEmbeddingQuery


storesText: boolean = true

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:152

BaseVectorStore.storesText

setCollection(coll): void

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:199

Setter for the collection property. Using a collection allows for simple segregation of vector data, e.g. by user, source, or access-level. Leave/set blank to ignore the collection value when querying.

string

Name for the collection.

void


getCollection(): string

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:210

Getter for the collection property. Using a collection allows for simple segregation of vector data, e.g. by user, source, or access-level. Leave/set blank to ignore the collection value when querying.

string

The currently-set collection value. Default is empty string.


client(): Promise<IsomorphicDB>

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:282

Connects to the database specified in environment vars. This method also checks and creates the vector extension, the destination table and indexes if not found.

Promise<IsomorphicDB>

A connection to the database, or the error encountered while connecting/setting up.

BaseVectorStore.client


clearCollection(): Promise<any[]>

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:291

Delete all vector records for the specified collection. NOTE: Uses the collection property controlled by setCollection/getCollection.

Promise<any[]>

The result of the delete query.


add(embeddingResults): Promise<string[]>

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:327

Adds vector record(s) to the table. NOTE: Uses the collection property controlled by setCollection/getCollection.

BaseNode<Metadata>[]

The Nodes to be inserted, optionally including metadata tuples.

Promise<string[]>

A list of zero or more id values for the created records.

BaseVectorStore.add


delete(refDocId, deleteKwargs?): Promise<void>

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:376

Deletes all nodes from the database that belong to the given document. NOTE: Uses the collection property controlled by setCollection/getCollection.

string

Reference document ID - all nodes with this ref_doc_id will be deleted.

object

Required by VectorStore interface. Currently ignored.

Promise<void>

Promise that resolves if the delete query did not throw an error.

BaseVectorStore.delete


query(query, options?): Promise<VectorStoreQueryResult>

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:511

Query the vector store for the closest matching data to the query embeddings

VectorStoreQuery

The VectorStoreQuery to be used

object

Required by VectorStore interface. Currently ignored.

Promise<VectorStoreQueryResult>

Zero or more Document instances with data from the vector store.

BaseVectorStore.query


persist(persistPath): Promise<void>

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:628

Required by VectorStore interface. Currently ignored.

string

Promise<void>

Resolved Promise.


exists(refDocId): Promise<boolean>

Defined in: packages/providers/storage/postgres/src/PGVectorStore.ts:636

Check if any nodes exist for the given document reference ID. Used for de-duplication during ingestion.

string

The reference document ID to check

Promise<boolean>

true if any nodes with this ref_doc_id exist

BaseVectorStore.exists