Skip to main content

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 equal
  • in - Value in array
  • nin - 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

  1. Choose appropriate index: HNSW for high recall, IVF for speed
  2. Use Zilliz Cloud for production: Managed, scalable solution
  3. Tune index parameters: Adjust M and efConstruction for HNSW
  4. Monitor memory: Milvus loads indexes into memory
  5. Batch operations: Insert documents in batches for better performance
  6. Regular compaction: Run compaction to optimize storage

Troubleshooting

Connection Refused

Ensure Milvus is running:

Collection Already Exists

Milvus auto-creates collections. To use existing collection:

Dimension Mismatch

Ensure embedding dimensions match:

See Also