Backends¶
Medha supports nine vector backends. Choose based on your infrastructure, persistence requirements, and scale.
Comparison¶
| Backend | Use Case | Persistence | Setup | Cloud-native | Extra |
|---|---|---|---|---|---|
memory |
Dev/testing | No | None | No | built-in |
qdrant |
General production | Yes | Docker/Cloud | Yes | [qdrant] |
pgvector |
Existing PostgreSQL | Yes | Postgres + extension | No | [pgvector] |
elasticsearch |
Search-heavy stacks | Yes | ES 8.x | Yes | [elasticsearch] |
vectorchord |
High-perf Postgres | Yes | Postgres + extension | No | [vectorchord] |
chroma |
Rapid prototyping | Optional | None/Docker | No | [chroma] |
weaviate |
Knowledge graph | Yes | Docker/Cloud | Yes | [weaviate] |
redis |
Low-latency cache | Optional | Redis Stack | Yes | [redis] |
azure_search |
Azure ecosystem | Yes | Managed | Yes | [azure-search] |
lancedb |
Embedded/serverless | Yes | None | Optional | [lancedb] |
memory — In-Memory¶
The default backend. Stores all vectors in a Python dict keyed by entry ID. Data is lost when the process exits. Ideal for unit tests and local development.
qdrant — Qdrant¶
Qdrant is the recommended production backend. It supports both an in-process mode (no server) and a full client-server deployment with gRPC/REST.
from medha import Settings
# Local Docker instance
settings = Settings(
backend_type="qdrant",
qdrant_host="localhost",
qdrant_port=6333,
)
# Qdrant Cloud
settings = Settings(
backend_type="qdrant",
qdrant_url="https://your-cluster.qdrant.tech",
qdrant_api_key="your-api-key",
)
Start a local Qdrant instance with Docker:
pgvector — PostgreSQL + pgvector¶
Uses the pgvector extension for PostgreSQL. Best choice if you already run Postgres and want to consolidate infrastructure.
from medha import Settings
settings = Settings(
backend_type="pgvector",
pg_dsn="postgresql://user:password@localhost:5432/mydb",
)
Install the extension in your database:
elasticsearch — Elasticsearch¶
Uses Elasticsearch 8.x dense vector fields and kNN search. Suitable for stacks already using Elasticsearch for full-text search.
from medha import Settings
settings = Settings(
backend_type="elasticsearch",
es_url="http://localhost:9200",
# es_api_key="..." for Elastic Cloud
)
vectorchord — VectorChord¶
VectorChord is a high-performance vector extension for PostgreSQL using IVF-PQ indexing. Recommended over pgvector for large-scale deployments (>1M entries).
from medha import Settings
settings = Settings(
backend_type="vectorchord",
pg_dsn="postgresql://user:password@localhost:5432/mydb",
)
chroma — Chroma¶
Chroma can run in-process (ephemeral) or as a server (persistent). Excellent for rapid prototyping and notebook environments.
from medha import Settings
# In-process (ephemeral)
settings = Settings(backend_type="chroma")
# HTTP client (persistent)
settings = Settings(
backend_type="chroma",
chroma_host="localhost",
chroma_port=8000,
)
weaviate — Weaviate¶
Weaviate is a knowledge-graph-oriented vector database with built-in schema management. Good for teams already using Weaviate or who need rich object properties alongside vectors.
from medha import Settings
settings = Settings(
backend_type="weaviate",
weaviate_url="http://localhost:8080",
# weaviate_api_key="..." for Weaviate Cloud
)
redis — Redis Stack¶
Uses Redis Stack's RediSearch module for vector similarity search. Delivers the lowest latency of any networked backend (< 1 ms P99 for small indexes). Persistence depends on your Redis configuration (RDB/AOF).
from medha import Settings
settings = Settings(
backend_type="redis",
redis_url="redis://localhost:6379",
)
Note
The redis backend uses Redis Stack, not vanilla Redis. Ensure RediSearch is available in your deployment.
azure_search — Azure AI Search¶
Fully managed vector search service on Azure. Recommended for teams running workloads in Azure that want zero infrastructure management.
from medha import Settings
settings = Settings(
backend_type="azure_search",
azure_search_endpoint="https://your-service.search.windows.net",
azure_search_api_key="your-admin-key",
)
lancedb — LanceDB¶
LanceDB is an embedded vector database that writes directly to disk (local or cloud object storage). No server required, making it ideal for serverless deployments or single-machine applications that need persistence.