pub struct PgVectorStore { /* private fields */ }Expand description
A VectorStore backed by PostgreSQL with the pgvector extension.
Use PgVectorStoreBuilder to construct.
Statements are prepared through deadpool’s per-connection statement cache
(prepare_cached), so the constant upsert/query/delete/count SQL is
parsed and planned once per pooled connection instead of per call.
Implementations§
Trait Implementations§
Source§impl VectorStore for PgVectorStore
impl VectorStore for PgVectorStore
Source§async fn upsert(
&self,
id: &str,
embedding: Vec<f32>,
document: Document,
) -> Result<()>
async fn upsert( &self, id: &str, embedding: Vec<f32>, document: Document, ) -> Result<()>
Inserts or updates a document with a pre-computed embedding vector.
Source§async fn upsert_many(
&self,
items: Vec<(String, Vec<f32>, Document)>,
) -> Result<()>
async fn upsert_many( &self, items: Vec<(String, Vec<f32>, Document)>, ) -> Result<()>
Inserts or updates a batch of documents with pre-computed embeddings. Read more
Source§async fn query(
&self,
embedding: Vec<f32>,
top_k: usize,
) -> Result<Vec<ScoredDocument>>
async fn query( &self, embedding: Vec<f32>, top_k: usize, ) -> Result<Vec<ScoredDocument>>
Queries the store for the
top_k most similar documents to the
given embedding vector. Returns results sorted by descending similarity.Auto Trait Implementations§
impl !RefUnwindSafe for PgVectorStore
impl !UnwindSafe for PgVectorStore
impl Freeze for PgVectorStore
impl Send for PgVectorStore
impl Sync for PgVectorStore
impl Unpin for PgVectorStore
impl UnsafeUnpin for PgVectorStore
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