Expand description
SZ-ORM pgvector Extension
Provides PostgreSQL pgvector vector similarity search capabilities, supporting three implementations:
- In-memory implementation (
InMemoryVectorStore): Pure Rust vector computation, no database connection, suitable for testing and benchmarking - Stub implementation (
StubVectorStore): All methods return Unsupported, suitable for debug placeholder - Real implementation (
RealPgVectorStore, requiresreal-pgfeature): Connects to PostgreSQL + pgvector via tokio-postgres
§Quick Start
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 extensions::AnnIndexDef;pub use extensions::AnnIndexRegistry;pub use extensions::AnnIndexType;pub use extensions::BatchOpsExt;pub use extensions::DimensionValidator;pub use extensions::HnswParams;pub use extensions::IvfflatParams;pub use extensions::MemoryBatchOps;pub use extensions::SimilarityAlgorithms;pub use extensions::VectorNormalizer;pub use extensions::MAX_VECTOR_DIMENSION;pub use extensions::MIN_VECTOR_DIMENSION;pub use memory::InMemoryVectorStore;pub use stub::StubVectorStore;
Modules§
- error
- Vector 操作错误类型
- extensions
- pgvector 深度扩展功能
- memory
- 内存实现:纯 Rust 向量计算(不连接数据库)
- stub
- Stub 实现:所有方法返回 Unsupported 错误
Structs§
- Search
Result - Search result
- Vector
Record - Vector record
Enums§
- Vector
Metric - Vector distance metric
Constants§
- MAX_
TOP_ K - M-16 fix: top_k maximum limit
Traits§
- PgVector
Store - Vector Store core trait
Functions§
- validate_
top_ k - M-16 fix: Validate whether top_k is within reasonable range