Expand description
SZ-ORM pgvector 扩展
提供 PostgreSQL pgvector 向量相似度搜索能力,支持三种实现:
- 内存实现(
InMemoryVectorStore):纯 Rust 向量计算,不连接数据库,适用于测试和基准 - Stub 实现(
StubVectorStore):所有方法返回 Unsupported,适用于调试占位 - 真实实现(
RealPgVectorStore,需启用real-pgfeature):通过 tokio-postgres 连接 PostgreSQL + pgvector
§快速入门
use sz_orm_vector::{InMemoryVectorStore, PgVectorStore, VectorRecord, VectorMetric};
let store = InMemoryVectorStore::new();
store.create_collection("docs", 3, None).await?;
let record = VectorRecord::new("doc1", vec![1.0, 0.0, 0.0]);
store.insert("docs", vec![record]).await?;
let results = store.search("docs", &[1.0, 0.0, 0.0], 5).await?;
println!("found {} results", results.len());Re-exports§
pub use error::VectorError;pub use memory::InMemoryVectorStore;pub use stub::StubVectorStore;
Modules§
Structs§
- Search
Result - 搜索结果
- Vector
Record - 向量记录
Enums§
- Vector
Metric - 向量距离度量
Constants§
- MAX_
TOP_ K - M-16 修复:top_k 最大限制
Traits§
- PgVector
Store - Vector Store 核心 trait
Functions§
- validate_
top_ k - M-16 修复:校验 top_k 是否在合理范围内