Registry /
llm-agents / llama-index-vector-stores-milvus
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 6.703s · 617.8MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 30.6s · import 5.303s · 580MB
585MB installed
● package 585MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
MilvusVectorStore
✓ from llama_index.vector_stores.milvus import MilvusVectorStore
VectorStoreIndex
✓ from llama_index.core import VectorStoreIndex
✗ from llama_index import VectorStoreIndex
Following LlamaIndex v0.10+ packaging, core components are now in `llama_index.core`.
This quickstart demonstrates how to set up `MilvusVectorStore`, load documents using `SimpleDirectoryReader`, create a `VectorStoreIndex`, and query it. It uses Milvus Lite by default for ease of local setup and relies on OpenAI for embeddings and LLM.
import os
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llama_index.vector_stores.milvus import MilvusVectorStore
from llama_index.core.settings import Settings
from llama_index.llms.openai import OpenAI
from llama_index.embeddings.openai import OpenAIEmbedding
# Set up OpenAI API key (replace with your actual key or use environment variable)
os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "sk-YOUR_OPENAI_API_KEY")
# Configure LlamaIndex settings
Settings.llm = OpenAI(model="gpt-3.5-turbo")
Settings.embed_model = OpenAIEmbedding(model="text-embedding-ada-002")
# 1. Prepare some dummy data
# Create a dummy data directory and file if they don't exist
if not os.path.exists("data"): os.makedirs("data")
with open("data/milvus_doc.txt", "w") as f:
f.write("The Milvus vector database is designed for AI applications and similarity search. It supports efficient storage and querying of billions of vectors. LlamaIndex provides a robust framework to integrate with various vector stores, including Milvus, to build powerful RAG systems. This integration allows users to leverage Milvus's capabilities for high-performance vector search within their LlamaIndex applications.")
# 2. Load documents
documents = SimpleDirectoryReader("data").load_data()
# 3. Initialize MilvusVectorStore (using Milvus Lite for local setup)
# For Milvus Lite, uri='./milvus.db' is convenient. For a Milvus server, use 'http://localhost:19530' or your server address.
# dim must match the dimension of your embedding model (e.g., 1536 for text-embedding-ada-002)
vector_store = MilvusVectorStore(
uri="./milvus_test.db",
dim=Settings.embed_model.embed_dimension,
collection_name="llama_index_milvus_collection",
overwrite=True # Set to True for a fresh start, False to append
)
# 4. Create an index
index = VectorStoreIndex.from_documents(documents, vector_store=vector_store)
# 5. Query the index
query_engine = index.as_query_engine()
response = query_engine.query("What is Milvus used for?")
print(response)
# To demonstrate loading an existing index (if overwrite was False or after a run)
# vector_store_load = MilvusVectorStore(
# uri="./milvus_test.db",
# dim=Settings.embed_model.embed_dimension,
# collection_name="llama_index_milvus_collection",
# overwrite=False
# )
# index_loaded = VectorStoreIndex.from_vector_store(vector_store_load)
# response_loaded = index_loaded.as_query_engine().query("What is LlamaIndex?")
# print(response_loaded)
Debug
Known issues
breakingLlamaIndex v0.10+ introduced a significant refactor, splitting integrations like Milvus into separate PyPI packages and deprecating `ServiceContext`. Core modules are now under `llama_index.core`.fixUpdate your `pip install` commands to include specific integration packages (e.g., `llama-index-vector-stores-milvus`). Adjust imports to use `llama_index.core` for core components (e.g., `VectorStoreIndex`, `Settings`). Use `Settings` object for global configurations instead of `ServiceContext`.
affects: >=0.10.0 of llama-index (and corresponding integration package versions)
gotchaThe `dim` parameter in `MilvusVectorStore` must exactly match the output dimension of your embedding model. Mismatched dimensions will lead to collection creation errors or data insertion failures.fixEnsure `dim` parameter matches your embedding model (e.g., 1536 for OpenAI's `text-embedding-ada-002`). You can get this from `Settings.embed_model.embed_dimension` if using LlamaIndex's `Settings`.
affects: All versions
gotchaIncorrect Milvus URI can lead to connection issues. A local file path (e.g., `./milvus.db`) uses Milvus Lite. A server address (e.g., `http://localhost:19530`) is required for a running Milvus server (Docker, Kubernetes, Zilliz Cloud).fixVerify your `uri` parameter: for Milvus Lite, use a local file path; for a Milvus server, use its correct network address. Ensure the Milvus server is running and accessible if using a network URI.
affects: All versions
gotchaStoring excessive non-defined metadata in documents can lead to 'Length of Dynamic Field Exceeding Max Length' errors in Milvus, as such data is often stored as a JSON string in a dynamic field.fixReduce the size of dynamic metadata or explicitly define schema fields for larger metadata values within Milvus to avoid hitting the default 65536-byte limit for dynamic fields.
affects: All versions
Upgrade
Version history
1.1.0latest on PyPI · released Mar 12, 2026
Audit
Dependencies
llama-indexrequiredCore LlamaIndex framework for data indexing and querying.
pymilvusrequiredPython client library for interacting with Milvus. Version >=2.4.2 is recommended for Milvus Lite.