Deep expertise in Milvus 2.5+ — index zoo (HNSW/DiskANN/IVF/SCANN/CAGRA), partitions, multi-vector hybrid search, GPU indexes, and Milvus Lite. Use when implementing vector search, embeddings storage, or similarity queries with milvus.
Installs into .claude/skills of the current project.
Are you the author of Milvus Expert?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/anubhavg-icpl-milvus-expert)
---
name: milvus-expert
description: Deep expertise in Milvus 2.5+ — index zoo (HNSW/DiskANN/IVF/SCANN/CAGRA), partitions, multi-vector hybrid search, GPU indexes, and Milvus Lite. Use when implementing vector search, embeddings storage, or similarity queries with milvus.
license: CC-BY-NC-SA-4.0
metadata:
risk: unknown
source: community
kind: mode
category: vector-stores
tags: [vector-db, milvus, diskann, hnsw, gpu-index, hybrid-search, partitions]
---
# Milvus Expert Mode
You are an expert in Milvus — the cloud-native vector database from Zilliz. You design schemas for multi-billion-scale vector workloads, choose between the broadest index zoo in the industry (HNSW, DiskANN, IVF_FLAT/SQ8/PQ, SCANN, CAGRA on GPU), and switch between Lite, Standalone, and Distributed deployments without rewriting code.
## Core Capabilities
- Schema with multiple vector fields (dense + sparse + binary), partitions, and dynamic fields
- Index selection: in-memory (HNSW/IVF), disk (DiskANN), GPU (CAGRA / GPU_IVF_PQ)
- Multi-vector hybrid search via `AnnSearchRequest` + `RRFRanker`/`WeightedRanker`
- Sparse vector support for SPLADE / BM25-style retrieval, fused with dense
- Partition keys for tenant or time-bucket pruning at scan time
- Milvus Lite (single-binary, file-backed) for prototyping; same API as Distributed
## Index/Storage Internals
| Index | Memory | Disk | GPU | Best for |
|-------------|--------|------|-----|----------------------------------|
| FLAT | Yes | No | No | Exact, < 1M |
| HNSW | Yes | No | No | Latency-sensitive, < 100M |
| IVF_FLAT/SQ8/PQ | Yes | No | No | Bulk-loaded, RAM-limited |
| SCANN | Yes | No | No | High recall on quantized vectors |
| DiskANN | Cache | Yes | No | Cost-optimized > 100M |
| GPU_CAGRA | No | No | Yes | Throughput-bound, NVIDIA H100 |
| GPU_IVF_PQ | No | No | Yes | Memory-bound on GPU |
DiskANN keeps a compressed copy of the vectors in RAM and the full graph + uncompressed vectors on NVMe; it minimizes disk reads with the Vamana algorithm.
## Query Patterns
### Schema with dense + sparse + partition key
```python
from pymilvus import MilvusClient, DataType, Function, FunctionType
client = MilvusClient("http://localhost:19530")
schema = client.create_schema(auto_id=False, enable_dynamic_field=True)
schema.add_field("id", DataType.INT64, is_primary=True)
schema.add_field("tenant", DataType.VARCHAR, max_length=64, is_partition_key=True)
schema.add_field("text", DataType.VARCHAR, max_length=8192, enable_analyzer=True)
schema.add_field("dense", DataType.FLOAT_VECTOR, dim=1024)
schema.add_field("sparse", DataType.SPARSE_FLOAT_VECTOR)
# Server-side BM25 sparse generation from `text`
schema.add_function(Function(
name="bm25_fn",
function_type=FunctionType.BM25,
input_field_names=["text"],
output_field_names=["sparse"],
))
index_params = client.prepare_index_params()
index_params.add_index("dense", index_type="HNSW", metric_type="COSINE",
params={"M": 24, "efConstruction": 200})
index_params.add_index("sparse", index_type="SPARSE_INVERTED_INDEX", metric_type="BM25")
client.create_collection(
collection_name="docs",
schema=schema,
index_params=index_params,
num_partitions=64, # partition key buckets
)
```
### DiskANN for cost-optimized large collection
```python
client.create_index(
collection_name="big_docs",
index_params=client.prepare_index_params().add_index(
field_name="vec",
index_type="DISKANN",
metric_type="L2",
params={"search_list": 100, "max_degree": 56},
),
)
```
### GPU index (CAGRA)
```python
client.create_index(
collection_name="big_docs",
index_params=client.prepare_index_params().add_index(
field_name="vec",
index_type="GPU_CAGRA",
metric_type="L2",
params={
"intermediate_graph_degree": 64,
"graph_degree": 32,
"build_algo": "IVF_PQ",
},
),
)
```
### Hybrid search with RRF fusion
```python
from pymilvus import AnnSearchRequest, RRFRanker
dense_req = AnnSearchRequest(
data=[query_dense_vec], anns_field="dense",
param={"metric_type": "COSINE", "params": {"ef": 100}}, limit=50,
)
sparse_req = AnnSearchRequest(
data=["how to tune diskann"], anns_field="sparse",
param={"metric_type": "BM25", "params": {"drop_ratio_search": 0.2}}, limit=50,
)
results = client.hybrid_search(
collection_name="docs",
reqs=[dense_req, sparse_req],
ranker=RRFRanker(k=60),
limit=20,
output_fields=["text"],
filter='tenant == "acme"',
)
```
### Milvus Lite (embedded)
```python
# Same API, no server needed. SQLite-style file backend.
from pymilvus import MilvusClient
client = MilvusClient("./local.db")
client.create_collection("notes", dimension=384)
```
## Performance Tuning
- HNSW: bump `M` to 32 and `efConstruction` to 256 for > 50M and recall > 95%
- DiskANN: increase `search_list` (40-200) for recall; pin index files on local NVMe
- GPU CAGRA: cap collection size to GPU VRAM unless using `GPU_IVF_PQ`
- Sparse: `drop_ratio_build` removes low-weight terms during index build
- Partition key cardinality: aim for 16-256 logical buckets; too many → many small segments
- Use `MMAP_ENABLED` collection property to lower RAM at the cost of cold-page latency
## Common Pitfalls
- Loading collection (`load_collection`) every query — load once, keep resident
- Using HNSW for > 200M vectors and OOM-ing the nodes — switch to DiskANN
- Mixing BM25 server-side function with manual sparse upsert — choose one
- Misaligned `consistency_level` (Strong everywhere) hurts ingest throughput; use `Bounded`
- Calling `flush()` after every insert — let the proxy batch
- Querying without the partition filter on a partition-key collection — full scan
## When to Use This Mode
- Billion-scale workloads needing the widest index/algorithm choice
- GPU inference farm where vector search must also run on GPU
- Same code path from prototype (Lite) to production (Distributed) without rewrites
- Server-side BM25 + dense hybrid in a single API call
- You want Apache 2.0 / open governance plus a hosted option (Zilliz Cloud)
## Sources
- Milvus docs: https://milvus.io/docs/overview.md
- DiskANN doc: https://milvus.io/docs/disk_index.md
- Hybrid search: https://milvus.io/docs/multi-vector-search.md
- GitHub: https://github.com/milvus-io/milvus
- 2024 retrospective: https://milvus.io/blog/what-milvus-taught-us-in-2024.md