Vector Stores Supported for Semantic Search in Code-Graph-RAG: Qdrant and Milvus Explained
Code-Graph-RAG supports both Qdrant and Milvus (including Milvus Lite) as vector store backends for semantic search, configurable via the VECTOR_STORE_BACKEND environment variable.
Code-Graph-RAG is an open-source retrieval-augmented generation framework for codebases that relies on semantic search to retrieve relevant code snippets. The project implements a unified vector store abstraction in codebase_rag/vector_store.py that supports multiple high-performance vector databases for embedding storage and similarity search. Understanding the vector stores supported for semantic search in Code-Graph-RAG helps you select the optimal backend for your infrastructure requirements.
Supported Vector Store Backends
Qdrant
Qdrant is an open-source vector database that stores embeddings in collections and executes cosine similarity search across high-dimensional vectors. According to the source code in codebase_rag/vector_store.py, the library initializes Qdrant connections through the get_qdrant_client factory function (lines 50-68) when the backend is configured for Qdrant operation.
Milvus and Milvus Lite
Milvus provides a high-performance vector engine optimized for large-scale similarity search. The Code-Graph-RAG implementation specifically detects Milvus Lite's cosine-distance quirks to ensure accurate similarity calculations. The MilvusVectorStore implementation resides in codebase_rag/vector_store.py (lines 32-35) and handles connections to both full Milvus deployments and lightweight Milvus Lite instances.
How Backend Selection Works
The system determines which vector store to use through the _selected_backend function in codebase_rag/vector_store.py (lines 30-42). This function reads the VECTOR_STORE_BACKEND setting from the project configuration—defined in codebase_rag/config.py—to instantiate the appropriate client.
The codebase_rag/constants/providers.py file defines the VectorStoreBackend enum with QDRANT and MILVUS values, which the configuration system validates against during initialization.
If the VECTOR_STORE_BACKEND environment variable does not match either "qdrant" or "milvus", the system logs a warning and disables vector store operations to prevent runtime errors.
Configuring the Vector Store Backend
Configure your backend by setting the environment variable before importing the library:
import os
os.environ["VECTOR_STORE_BACKEND"] = "qdrant" # or "milvus"
The codebase_rag/utils/dependencies.py module verifies that optional dependencies (pymilvus or qdrant-client) are installed before attempting to initialize the selected backend.
Performing Semantic Search Operations
Once configured, the unified API abstracts backend differences. Use search_embeddings to query vectors against your indexed codebase:
from codebase_rag.vector_store import search_embeddings
# query_vec is a list[float] embedding produced by the embedder
results = search_embeddings(query_vec, top_k=5, project="my_project")
# Returns: [(node_id, similarity_score), ...]
print(results)
To store embeddings, use the batch insertion function regardless of which backend is active:
from codebase_rag.vector_store import store_embedding_batch
points = [
(123, [0.12, 0.45, ...], "my_project.module.Class.method"),
(124, [0.33, 0.67, ...], "my_project.module.OtherClass.func"),
]
stored = store_embedding_batch(points)
print(f"Stored {stored} embeddings")
Summary
- Dual backend support: Code-Graph-RAG supports both Qdrant and Milvus (including Milvus Lite) for semantic search operations.
- Unified interface: The
search_embeddingsandstore_embedding_batchfunctions incodebase_rag/vector_store.pyprovide backend-agnostic vector operations. - Configuration-driven: Set
VECTOR_STORE_BACKENDto"qdrant"or"milvus"in your environment to select the active implementation. - Dependency validation: The system checks for
pymilvusorqdrant-clientavailability incodebase_rag/utils/dependencies.pybefore initializing the vector store. - Automatic fallback: The system disables vector operations with a warning if an unsupported backend is specified.
Frequently Asked Questions
What vector stores does Code-Graph-RAG support?
Code-Graph-RAG supports Qdrant and Milvus (including Milvus Lite) as its vector store backends for semantic search. The backend is selected via the VECTOR_STORE_BACKEND environment variable, and the implementation details are handled in codebase_rag/vector_store.py.
How do I switch between Qdrant and Milvus in Code-Graph-RAG?
Set the VECTOR_STORE_BACKEND environment variable to either "qdrant" or "milvus" before running your application. The _selected_backend function in codebase_rag/vector_store.py (lines 30-42) automatically instantiates the correct client based on this setting, using get_qdrant_client for Qdrant or MilvusVectorStore for Milvus.
Does Code-Graph-RAG handle Milvus Lite differently from standard Milvus?
Yes, the codebase specifically detects Milvus Lite's cosine-distance quirks in the MilvusVectorStore implementation. While the configuration uses the same "milvus" backend identifier, the library adjusts similarity calculations to account for Lite-specific behavior during vector comparison operations.
What happens if I specify an unsupported vector store backend?
If the VECTOR_STORE_BACKEND value does not match "qdrant" or "milvus", the system logs a warning and disables vector store operations entirely. This prevents runtime errors while alerting you to configuration issues, as implemented in the _selected_backend logic within codebase_rag/vector_store.py.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →