pub struct PgvectorAdapter { /* private fields */ }Expand description
A search backend that stores and queries vectors via pgvector.
Compile-time availability of the postgres connection depends on the
live-db feature flag. Without it, all methods return
BackendError::Adapter("live-db feature required").
Implementations§
Source§impl PgvectorAdapter
impl PgvectorAdapter
Sourcepub fn new(table: impl Into<String>) -> Result<Self, BackendError>
pub fn new(table: impl Into<String>) -> Result<Self, BackendError>
Create a new adapter for the given table (stub without live-db).
Only validates the table name; all operational methods will return an
error until the live-db feature is enabled.
§Errors
Returns Err if table fails the allowlist regex validation.
Sourcepub fn ensure_schema(&mut self, dim: usize) -> Result<(), BackendError>
pub fn ensure_schema(&mut self, dim: usize) -> Result<(), BackendError>
Create the vector extension and the vectors table if they do not
exist.
§Errors
Returns Err when the live-db feature is disabled, or on any
postgres::Error.
Sourcepub fn ensure_index(&self, lists: u32) -> Result<(), BackendError>
pub fn ensure_index(&self, lists: u32) -> Result<(), BackendError>
Create an approximate nearest-neighbour index on the embedding column.
lists controls the number of IVFFlat lists. If 0, defaults to 100.
§Errors
Returns Err when the live-db feature is disabled, or on any
postgres::Error.
Trait Implementations§
Source§impl SearchBackend for PgvectorAdapter
impl SearchBackend for PgvectorAdapter
Source§fn ingest(
&mut self,
vectors: &[(VectorId, Vec<f32>)],
) -> Result<(), BackendError>
fn ingest( &mut self, vectors: &[(VectorId, Vec<f32>)], ) -> Result<(), BackendError>
(VectorId, Vec<f32>) pairs. Read more