Overview
Milvus is an open-source vector database built for scalable similarity search and AI applications. It supports billions of vectors with millisecond search performance.Installation
Basic Usage
Constructor Options
MilvusClient
Existing Milvus client instance
ClientConfig | string
Milvus server address (defaults to
MILVUS_ADDRESS env var)boolean
Enable SSL connection (defaults to
MILVUS_SSL env var)string
Milvus username (defaults to
MILVUS_USERNAME env var)string
Milvus password (defaults to
MILVUS_PASSWORD env var)string
default:"llamacollection"
Collection name for storing vectors
string
default:"id"
Field name for storing node IDs
string
default:"content"
Field name for storing text content
string
default:"metadata"
Field name for storing metadata (as JSON)
string
default:"embedding"
Field name for storing embedding vectors
Configuration
Environment Variables
With Custom Client
Running Milvus
Docker Compose
Docker
Zilliz Cloud
Sign up at Zilliz Cloud for managed Milvus:Collection Management
Milvus automatically creates collections with this schema:Querying
Basic Query
Metadata Filtering
Supported Filter Operators
Milvus supports:==- Equal!=- Not equal<- Less than<=- Less than or equal>- Greater than>=- Greater than or equalin- Value in arraynin- Value not in array (converted to multiple!=checks)
Managing Data
Add Documents
Delete by Document ID
Access Milvus Client
Complete Example
Index Types
Milvus supports various index types for different use cases:- FLAT: Exact search (best for small datasets)
- IVF_FLAT: Inverted file with flat compression
- IVF_SQ8: IVF with scalar quantization
- IVF_PQ: IVF with product quantization
- HNSW: Hierarchical Navigable Small World graph (best for high recall)
- ANNOY: Approximate Nearest Neighbors Oh Yeah
Performance Tuning
Custom Collection Configuration
Best Practices
- Choose appropriate index: HNSW for high recall, IVF for speed
- Use Zilliz Cloud for production: Managed, scalable solution
- Tune index parameters: Adjust M and efConstruction for HNSW
- Monitor memory: Milvus loads indexes into memory
- Batch operations: Insert documents in batches for better performance
- Regular compaction: Run compaction to optimize storage