| Crates.io | ruvector-collections |
| lib.rs | ruvector-collections |
| version | 0.1.30 |
| created_at | 2025-11-26 16:08:22.032551+00 |
| updated_at | 2026-01-04 19:40:34.316458+00 |
| description | High-performance collection management for Ruvector vector databases |
| homepage | |
| repository | https://github.com/ruvnet/ruvector |
| max_upload_size | |
| id | 1951682 |
| size | 98,318 |
High-performance collection management for Ruvector vector databases.
ruvector-collections provides multi-tenant collection support with isolated namespaces, schema management, and collection-level configuration. Part of the Ruvector ecosystem.
Add ruvector-collections to your Cargo.toml:
[dependencies]
ruvector-collections = "0.1.1"
use ruvector_collections::{CollectionManager, CollectionConfig, Schema};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create collection manager
let manager = CollectionManager::new()?;
// Define collection schema
let schema = Schema {
dimensions: 384,
distance_metric: DistanceMetric::Cosine,
vector_type: VectorType::Float32,
};
// Create collection with config
let config = CollectionConfig {
name: "documents".to_string(),
schema,
description: Some("Document embeddings".to_string()),
metadata: serde_json::json!({
"model": "text-embedding-3-small",
"created_by": "data-pipeline"
}),
..Default::default()
};
let collection = manager.create_collection(config)?;
println!("Created collection: {}", collection.id);
Ok(())
}
use ruvector_collections::CollectionManager;
let manager = CollectionManager::new()?;
// List all collections
for collection in manager.list_collections()? {
println!("{}: {} vectors", collection.name, collection.count);
}
// Get collection by name
let docs = manager.get_collection("documents")?;
// Update collection metadata
manager.update_collection("documents", |c| {
c.metadata["last_updated"] = serde_json::json!(chrono::Utc::now());
})?;
// Delete collection
manager.delete_collection("old_collection")?;
// Create alias for collection
manager.create_alias("docs", "documents_v2")?;
// Swap alias to new collection (zero-downtime migration)
manager.swap_alias("docs", "documents_v3")?;
// Access via alias
let collection = manager.get_collection_by_alias("docs")?;
// Collection configuration
pub struct CollectionConfig {
pub name: String,
pub schema: Schema,
pub description: Option<String>,
pub metadata: serde_json::Value,
pub replicas: usize,
pub shards: usize,
}
// Vector schema
pub struct Schema {
pub dimensions: usize,
pub distance_metric: DistanceMetric,
pub vector_type: VectorType,
}
// Collection info
pub struct Collection {
pub id: Uuid,
pub name: String,
pub schema: Schema,
pub count: usize,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub metadata: serde_json::Value,
}
impl CollectionManager {
pub fn new() -> Result<Self>;
pub fn create_collection(&self, config: CollectionConfig) -> Result<Collection>;
pub fn get_collection(&self, name: &str) -> Result<Option<Collection>>;
pub fn list_collections(&self) -> Result<Vec<Collection>>;
pub fn update_collection<F>(&self, name: &str, f: F) -> Result<Collection>;
pub fn delete_collection(&self, name: &str) -> Result<bool>;
pub fn create_alias(&self, alias: &str, collection: &str) -> Result<()>;
pub fn delete_alias(&self, alias: &str) -> Result<bool>;
}
MIT License - see LICENSE for details.