pub struct PgVectorStoreBuilder { /* private fields */ }Expand description
Builds a PgVectorStore with connection pooling and optional auto-migration.
§Example
ⓘ
use daimon_plugin_pgvector::{PgVectorStoreBuilder, DistanceMetric};
let store = PgVectorStoreBuilder::new("host=localhost dbname=mydb", 1536)
.table("embeddings")
.distance_metric(DistanceMetric::Cosine)
.hnsw_m(16)
.hnsw_ef_construction(64)
.auto_migrate(true)
.build()
.await?;Implementations§
Source§impl PgVectorStoreBuilder
impl PgVectorStoreBuilder
Sourcepub fn new(connection_string: impl Into<String>, dimensions: usize) -> Self
pub fn new(connection_string: impl Into<String>, dimensions: usize) -> Self
Creates a new builder.
connection_string: PostgreSQL connection string (e.g."host=localhost dbname=mydb user=postgres"or"postgresql://user:pass@host/db")dimensions: the fixed vector dimension count (must match your embedding model)
Sourcepub fn table(self, table: impl Into<String>) -> Self
pub fn table(self, table: impl Into<String>) -> Self
Sets the table name. Default: "daimon_vectors".
Sourcepub fn distance_metric(self, metric: DistanceMetric) -> Self
pub fn distance_metric(self, metric: DistanceMetric) -> Self
Sets the distance metric. Default: DistanceMetric::Cosine.
Sourcepub fn auto_migrate(self, enabled: bool) -> Self
pub fn auto_migrate(self, enabled: bool) -> Self
Enables or disables automatic schema creation on first connection.
Default: true.
When disabled, use the SQL from crate::migrations to set up
the schema manually.
Sourcepub fn hnsw_m(self, m: usize) -> Self
pub fn hnsw_m(self, m: usize) -> Self
Sets the HNSW m parameter (max connections per layer).
None uses the PostgreSQL default (16).
Sourcepub fn hnsw_ef_construction(self, ef: usize) -> Self
pub fn hnsw_ef_construction(self, ef: usize) -> Self
Sets the HNSW ef_construction parameter (build-time search width).
None uses the PostgreSQL default (64).
Sourcepub fn pool_size(self, size: usize) -> Self
pub fn pool_size(self, size: usize) -> Self
Sets the maximum number of connections in the pool. Default: 16.
Sourcepub async fn build(self) -> Result<PgVectorStore>
pub async fn build(self) -> Result<PgVectorStore>
Builds the PgVectorStore, optionally running migrations.
Auto Trait Implementations§
impl Freeze for PgVectorStoreBuilder
impl RefUnwindSafe for PgVectorStoreBuilder
impl Send for PgVectorStoreBuilder
impl Sync for PgVectorStoreBuilder
impl Unpin for PgVectorStoreBuilder
impl UnsafeUnpin for PgVectorStoreBuilder
impl UnwindSafe for PgVectorStoreBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more