class

CrigPostgres::PostgresVectorStore(E)

Inherits Reference < Object

PostgreSQL vector store implementation

Constructors

new(embedding_model : E, db : DB::Database, documents_table : String = "documents", distance_function : PgVectorDistanceFunction = PgVectorDistanceFunction::Cosine)
Source
with_defaults(model : E, db : DB::Database) : self forall E
Source

Instance methods

create_table(dims : Int32) : Nil

Create the documents table with pgvector support

Source
insert_documents(documents : Array(Tuple(T, Array(Embedding)))) : Nil forall T

Insert documents with their embeddings

Source
top_n(req : VectorSearchRequest(PgSearchFilter), type : D.class) : Array(Tuple(Float64, String, D)) forall D

Find top N similar documents

Source
top_n_ids(req : VectorSearchRequest(PgSearchFilter)) : Array(Tuple(Float64, String))

Find top N similar document IDs only

Source