Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Milvus

Milvus is a purpose-built vector database designed for billion-scale Approximate Nearest Neighbor Search (ANNS). The synaptic-rag (with feature milvus) crate implements the VectorStore trait using the Milvus REST API v2.

Setup

Add the feature flag to your Cargo.toml:

[dependencies]
synaptic = { version = "0.4", features = ["milvus"] }

Run Milvus locally with Docker:

docker run -d --name milvus-standalone \
  -p 19530:19530 -p 9091:9091 \
  milvusdb/milvus:latest standalone

Usage

use synaptic::milvus::{MilvusConfig, MilvusVectorStore};
use synaptic::core::VectorStore;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = MilvusConfig::new("http://localhost:19530", "my_collection", 1536);
    let store = MilvusVectorStore::new(config);

    // Create the collection (idempotent — safe to call on every startup)
    store.initialize().await?;

    // Add documents
    // store.add_documents(docs, &embeddings).await?;

    // Search
    // let results = store.similarity_search("query text", 5, &embeddings).await?;

    Ok(())
}

Zilliz Cloud

For Zilliz Cloud (managed Milvus), add your API key:

let config = MilvusConfig::new("https://your-cluster.zillizcloud.com", "collection", 1536)
    .with_api_key("your-api-key");

Configuration

FieldTypeDescription
endpointStringMilvus endpoint URL (e.g., http://localhost:19530)
collectionStringCollection name
dimusizeVector dimension — must match your embedding model
api_keyOption<String>API key for Zilliz Cloud authentication