Expand description
§Lumos Vector PostgreSQL
PostgreSQL with pgvector implementation for the lumos-vector-core architecture.
This crate provides a PostgreSQL backend with pgvector extension for vector storage, implementing the unified VectorStorage trait from lumos-vector-core.
§Features
- SQL Integration: Leverages PostgreSQL’s ACID properties
- pgvector Extension: High-performance vector operations
- Rich Queries: Complex SQL queries with vector similarity
- Transactions: Full transaction support
- Indexing: Multiple vector index types (IVFFlat, HNSW)
§Example
use lumos_vector_postgres::PostgresVectorStorage;
use lumos_vector_core::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create PostgreSQL storage
let storage = PostgresVectorStorage::new("postgresql://user:pass@localhost/db").await?;
// Create an index
let config = IndexConfig::new("documents", 384)
.with_metric(SimilarityMetric::Cosine);
storage.create_index(config).await?;
// Insert documents
let docs = vec![
Document::new("doc1", "Hello world")
.with_embedding(vec![0.1; 384])
.with_metadata("type", "greeting"),
];
storage.upsert_documents("documents", docs).await?;
Ok(())
}
Re-exports§
pub use storage::PostgresVectorStorage;
pub use config::PostgresConfig;
pub use error::PostgresError;
pub use error::PostgresResult;
Modules§
- config
- PostgreSQL configuration for vector storage
- error
- Error types for PostgreSQL vector storage
- filter
- Default filter evaluator implementation
- similarity
- Default similarity calculator implementations
- storage
- PostgreSQL vector storage implementation
Structs§
- Backend
Info - Backend information
- Cache
Config - 缓存配置
- Cache
Entry - 缓存条目
- Cache
Stats - 缓存统计信息
- Connection
Pool - 连接池
- Connection
Pool Config - 连接池配置
- Connection
Pool Stats - 连接池统计信息
- Document
- Document representation with embedding support
- Index
Config - Index configuration
- Index
Create Config - Index creation configuration
- Index
Info - Index statistics and information
- Index
Options - Index-specific options
- LRUCache
- LRU缓存
- Performance
Metrics - 性能指标
- Performance
Monitor - 性能监控器
- Pooled
Connection - 池化连接
- Search
Config - Search configuration
- Search
Request - Search request for querying vectors
- Search
Response - Search response
- Search
Result - Search result item
- Storage
Config Builder - Builder for creating storage configurations
- Vector
System Config - Complete vector storage system configuration
Enums§
- Embedding
Config - Embedding model configuration
- Filter
Condition - Filter conditions for querying vectors
- Metadata
Value - Metadata value that can hold various types
- Search
Query - Search query can be either a vector or text
- Similarity
Metric - Similarity metrics for vector comparison
- Sqlite
Synchronous - SQLite synchronous mode
- Storage
Config - Storage backend configuration
- Vector
Error - Comprehensive error type for vector storage operations
Traits§
- Embeddable
- Trait for documents that can be embedded
- Embedding
Model - Trait for embedding models
- Filter
Evaluator - Trait for filter evaluation
- Similarity
Calculator - Trait for vector similarity calculation
- Vector
Storage - Core trait for vector storage backends
Functions§
- create_
postgres_ storage - Create a new PostgreSQL vector storage instance
- create_
postgres_ storage_ with_ config - Create a new PostgreSQL vector storage instance with configuration
Type Aliases§
- Document
Id - Document ID type
- Metadata
- Metadata type for storing arbitrary key-value pairs
- Result
- Result type alias for vector operations
- Vector
- Vector type alias for f32 vectors