Skip to main content

Crate entelix_memory_pgvector

Crate entelix_memory_pgvector 

Source
Expand description

§entelix-memory-pgvector

Concrete entelix_memory::VectorStore implementation backed by Postgres + the pgvector extension.

Companion to the trait-only entelix_memory crate: sqlx + pgvector specifics live here so users who plug their own VectorStore pay nothing in compile time.

§One-call setup

use entelix_memory_pgvector::{DistanceMetric, IndexKind, PgVectorStore};

let store = PgVectorStore::builder(1536)
    .with_connection_string("postgres://localhost/entelix")
    .with_distance(DistanceMetric::Cosine)
    .with_index_kind(IndexKind::Hnsw)
    .build()
    .await?;

§Multi-tenancy

Single-table design with a composite (namespace_key, doc_id) primary key. Every read / write / count / list rides a WHERE namespace_key = $1 anchor — invariant 11 / F2 demand structural tenant isolation, and the composite PK doubles as the B-tree index that anchor relies on.

§Schema-as-code escape hatch

Operators that own the schema externally (DBA-managed, IaC, migration pipeline) call PgVectorStoreBuilder::with_auto_migrate with false — the builder skips extension creation, table creation, and index provisioning, trusting the operator to have stamped them.

Structs§

PgVectorStore
Concrete VectorStore backed by Postgres + pgvector.
PgVectorStoreBuilder
Builder for PgVectorStore.

Enums§

DistanceMetric
Distance metric used for vector similarity. Mirrors pgvector’s own taxonomy 1:1 — operators familiar with <=> / <-> / <#> pick the metric they would have picked there.
IndexKind
ANN index kind. HNSW is the production default; IVFFlat is selected when build time matters more than query latency.
PgVectorStoreError
Errors that can surface from PgVectorStore.

Type Aliases§

PgVectorStoreResult
Result alias used inside entelix-memory-pgvector.