Router CLI (ruvector)
High-performance command-line interface for the Ruvector vector database.
The
ruvectorCLI provides powerful tools for managing, testing, and benchmarking vector databases with sub-millisecond performance. Perfect for development, testing, and operational workflows.
๐ Features
- โก Fast Operations: Sub-millisecond vector operations with HNSW indexing
- ๐ง Database Management: Create, configure, and manage vector databases
- ๐ Performance Benchmarking: Built-in benchmarks for insert and search operations
- ๐ Real-time Statistics: Monitor database metrics and performance
- ๐ฏ Production Ready: Battle-tested CLI for operational workflows
- ๐ ๏ธ Developer Friendly: Intuitive commands with helpful output formatting
๐ฆ Installation
From Crates.io (Recommended)
From Source
# Clone the repository
# Build and install from workspace
Verify Installation
โก Quick Start
Create a Database
# Create a database with default settings (384 dimensions, cosine similarity)
# Create with custom configuration
Insert Vectors
# Insert a single vector
Search Similar Vectors
# Search for top 10 similar vectors
View Statistics
# Get database statistics and metrics
Run Benchmarks
# Benchmark with 1000 vectors of 384 dimensions
๐ Command Reference
create - Create Vector Database
Create a new vector database with specified configuration.
Usage:
Options:
-p, --path <PATH>- Database file path (default:./vectors.db)-d, --dimensions <DIMS>- Vector dimensions (default:384)-m, --metric <METRIC>- Distance metric (default:cosine)
Distance Metrics:
cosine- Cosine similarity (best for normalized vectors)euclidean,l2- Euclidean distancedot,dotproduct- Dot product similaritymanhattan,l1- Manhattan distance
Examples:
# Create database for sentence embeddings (384D)
# Create database for image embeddings (512D, L2 distance)
# Create database for large language model embeddings (1536D)
insert - Insert Vector
Insert a single vector into the database.
Usage:
Options:
-p, --path <PATH>- Database file path (default:./vectors.db)-i, --id <ID>- Unique vector identifier (required)-v, --vector <VECTOR>- Comma-separated vector values (required)
Examples:
# Insert a document embedding
# Insert into specific database
Performance:
- Typical insert latency: <1ms
- Includes HNSW index update
- Thread-safe for concurrent inserts
search - Search Similar Vectors
Search for the most similar vectors in the database.
Usage:
Options:
-p, --path <PATH>- Database file path (default:./vectors.db)-v, --vector <VECTOR>- Query vector (comma-separated values, required)-k <K>- Number of results to return (default:10)
Examples:
# Find 10 most similar vectors
# Find top 100 matches with specific database
Output Format:
โ Found 10 results
Query time: 423ยตs
1. doc_001 (score: 0.9823)
2. doc_045 (score: 0.9456)
3. doc_123 (score: 0.9234)
...
Performance:
- Typical query latency: <0.5ms (p50)
- HNSW-based approximate nearest neighbor search
- 95%+ recall accuracy
stats - Database Statistics
Display comprehensive database statistics and performance metrics.
Usage:
Options:
-p, --path <PATH>- Database file path (default:./vectors.db)
Example:
Output:
โ Database Statistics
Total vectors: 50,000
Average query latency: 423.45 ฮผs
QPS: 2,361.23
Index size: 12,345,678 bytes
Metrics Explained:
- Total vectors: Number of vectors stored
- Average query latency: Mean search time in microseconds
- QPS: Queries per second (throughput)
- Index size: HNSW index size in bytes
benchmark - Performance Benchmarking
Run comprehensive performance benchmarks for insert and search operations.
Usage:
Options:
-p, --path <PATH>- Database file path (default:./vectors.db)-n, --num-vectors <N>- Number of vectors to test (default:1000)-d, --dimensions <DIMS>- Vector dimensions (default:384)
Examples:
# Standard benchmark (1K vectors, 384D)
# Large-scale benchmark (100K vectors, 768D)
# Quick test (100 vectors)
Output:
โ Running benchmark...
Vectors: 1000
Dimensions: 384
โ Generating vectors...
โ Inserting vectors...
โ Inserted 1000 vectors in 1.234s
Throughput: 810 inserts/sec
โ Running search benchmark...
โ Completed 100 queries in 42.3ms
Average latency: 423ยตs
QPS: 2,364
Benchmark Process:
- Generates random vectors with specified dimensions
- Measures batch insert performance
- Runs 100 search queries
- Reports throughput and latency metrics
๐ฏ Use Cases
Development Workflows
# 1. Create database for development
# 2. Insert test vectors
# 3. Test search functionality
# 4. Monitor performance
Performance Testing
# Test different vector sizes
for; do
done
# Compare distance metrics
for; do
done
Production Operations
# Check production database health
# Benchmark production-scale data
# Verify search performance
๐ง Configuration
Database Configuration
The CLI uses the router-core configuration system with the following defaults:
VectorDbConfig
HNSW Parameters
M (connections per node):
- Lower values (16): Less memory, slower search
- Higher values (64): More memory, faster search
- Default: 32 (balanced)
ef_construction:
- Build-time quality parameter
- Higher = better index quality, slower construction
- Default: 200
ef_search:
- Search-time accuracy parameter
- Higher = better recall, slower search
- Default: 100
Distance Metrics
Choose based on your data characteristics:
| Metric | Best For | Normalization Required |
|---|---|---|
| Cosine | Text embeddings, semantic search | Yes (recommended) |
| Euclidean | Image embeddings, spatial data | No |
| Dot Product | Pre-normalized vectors | Yes (required) |
| Manhattan | High-dimensional sparse data | No |
๐ Performance Tuning
Optimize for Speed
# Use dot product for pre-normalized vectors (fastest)
# Reduce ef_search for faster queries (lower recall)
# Note: Currently requires code modification
Optimize for Accuracy
# Use higher dimensions for better semantic separation
# Use cosine similarity for normalized embeddings
Optimize for Memory
# Use lower dimensions
# Consider quantization (requires code configuration)
# Product quantization: 4-8x memory reduction
# Scalar quantization: 4x memory reduction
๐ Integration with Router Core
The CLI is built on router-core and provides access to its features:
Core Features
- HNSW Indexing: Fast approximate nearest neighbor search
- Multiple Distance Metrics: Cosine, Euclidean, Dot Product, Manhattan
- SIMD Optimization: Hardware-accelerated vector operations
- Memory Mapping: Efficient large-scale data handling
- Thread Safety: Concurrent operations support
- Persistent Storage: Durable vector storage with redb
API Compatibility
The CLI uses the same VectorDB API available in Rust applications:
use ;
// Same underlying implementation as CLI
let db = builder
.dimensions
.storage_path
.build?;
๐ Troubleshooting
Common Issues
Database not found:
# Ensure you've created the database first
# Or specify the correct path
Dimension mismatch:
# Error: Expected 384 dimensions, got 768
# Solution: Use consistent dimensions
Parse errors:
# Ensure vector values are comma-separated floats
# Not: "0.1 0.2 0.3" or "[0.1,0.2,0.3]"
Performance Issues
Slow inserts:
- Use batch insert operations in your application code
- Reduce
hnsw_ef_constructionfor faster builds - Consider quantization for very large datasets
Slow searches:
- Reduce
k(number of results) - Reduce
ef_searchparameter (requires code modification) - Ensure proper distance metric for your data
๐ Examples
RAG System Vector Database
# Create database for document embeddings
# Insert document embeddings (from your application)
# Typically done via Rust/Node.js API, not CLI
# Search for relevant documents
Semantic Search Testing
# Create test database
# Run benchmark to establish baseline
# Test search with different query vectors
for; do
done
Performance Comparison
# Compare metrics
metrics=("cosine" "euclidean" "dot" "manhattan")
for; do
done
๐ Related Documentation
Ruvector Core Documentation
- Ruvector Main README - Complete project overview
- Router Core API - Core library documentation
- Rust API Reference - Detailed API docs
- Performance Tuning - Optimization guide
Getting Started
- Quick Start Guide - 5-minute tutorial
- Installation Guide - Detailed setup
- Basic Tutorial - Step-by-step guide
Advanced Topics
- Advanced Features - Quantization, indexing
- Benchmarking Guide - Performance testing
- Build Optimization - Compilation tips
๐ค Contributing
We welcome contributions! Here's how to contribute to the router-cli:
- Fork the repository at github.com/ruvnet/ruvector
- Create a feature branch (
git checkout -b feature/cli-improvement) - Make your changes to
crates/router-cli/ - Test thoroughly:
- Build and test the binary:
- Commit your changes (
git commit -m 'Add amazing CLI feature') - Push to the branch (
git push origin feature/cli-improvement) - Open a Pull Request
Development Setup
# Clone and navigate to CLI crate
# Build in development mode
# Run with cargo
# Run tests
# Run with detailed logging
RUST_LOG=debug
๐ License
MIT License - see LICENSE for details.
Part of the Ruvector project by rUv.
๐ Acknowledgments
Built with:
- clap - Command-line argument parsing
- colored - Terminal color output
- router-core - Vector database engine
- chrono - Timestamp handling