Key features
- Partition-key isolation: Physical data separation for millions of tenants
- Hybrid search: RRF or weighted fusion of dense and sparse vectors
- JSON path indexing: Efficient filtering on nested metadata
- HNSW indexing: Fast approximate nearest neighbor search
- Zilliz Cloud: Fully managed service with auto-scaling
- Self-hosted: Open-source deployment with Docker or Kubernetes
Installation
Connection
Zilliz Cloud
Self-hosted Milvus
Legacy host/port format
Collection creation
Basic collection
With sparse vectors for hybrid search
With partition keys for multi-tenancy
Recreate existing collection
JSON path indexing
Create indexes on nested metadata fields for fast filtering:VARCHAR: String valuesDOUBLE: Numeric valuesBOOL: Boolean values
Inserting documents
From Haystack documents
With sparse embeddings
Searching
Dense vector search
Hybrid search with RRF
Reciprocal Rank Fusion (default, parameter-free):Hybrid search with weighted ranker
Explicit control over dense vs. sparse balance:Metadata filtering
Supported filter operators
$eq: Equal to$gt: Greater than$lt: Less than$in: Value in list$contains: JSON array contains value
Sparse-only search
Metadata-only query
Multi-tenancy with partition keys
Setup partition-based isolation
Partition keys provide physical data isolation at the storage layer, making multi-tenant queries significantly faster than post-filtering. Milvus supports millions of tenants efficiently.
Deleting documents
Delete by IDs
Delete by filter
Delete namespace
Building filter expressions
Dropping collections
Advanced configuration
HNSW index parameters
Milvus creates HNSW indexes automatically with these defaults:src/vectordb/databases/milvus.py:253.
Sparse index configuration
Sparse vectors useSPARSE_INVERTED_INDEX with inner product metric:
Best practices
Partition keys for large-scale multi-tenancy
Partition keys for large-scale multi-tenancy
Use partition keys when serving thousands to millions of tenants:
JSON path indexes for complex filtering
JSON path indexes for complex filtering
Create indexes on frequently filtered fields:
Choose the right ranker for hybrid search
Choose the right ranker for hybrid search
- RRF: Best for most use cases, no tuning needed
- Weighted: When you know the optimal dense/sparse balance
Memory management
Memory management
Milvus loads collections into memory for fast search:
- Monitor memory usage with large collections
- Use
drop_collection()to free memory - Consider Qdrant with quantization for memory-constrained environments
Error handling
Source reference
Implementation:src/vectordb/databases/milvus.py
Key classes and methods:
MilvusVectorDB.__init__(): src/vectordb/databases/milvus.py:103create_collection(): src/vectordb/databases/milvus.py:150create_json_index(): src/vectordb/databases/milvus.py:272insert_documents(): src/vectordb/databases/milvus.py:332search(): src/vectordb/databases/milvus.py:398delete_documents(): src/vectordb/databases/milvus.py:742