Key features
- Local persistent storage: File-based storage without external dependencies
- Ephemeral mode: In-memory databases for testing
- Cloud deployment: Hosted Chroma instances
- Hybrid search: Experimental support for dense + sparse vectors
- Multi-tenancy: Tenant and database isolation
- Metadata filtering: Chroma-native filter syntax
Installation
Chroma requires pysqlite3 for compatibility:Connection
Local persistent client
Default mode for development:Ephemeral client
In-memory for testing:Cloud/remote client
From config file
configs/chroma.yaml
Collection creation
Basic collection
With custom embedding function
With metadata
Upserting documents
From Haystack documents
From raw dictionaries
Chroma automatically flattens nested metadata. Nested dicts use dot notation:
{"user.id": 123} instead of {"user": {"id": 123}}.Querying
Vector search
Text search with auto-embedding
Requires collection with embedding function:Metadata filtering
Chroma uses its own filter syntax:Document content filtering
Hybrid search (experimental)
Chroma’s hybrid search is available on hosted/cloud instances:Hybrid search requires Chroma 0.6.0+ and hosted/cloud environments. Local instances fall back to standard query().
Multi-tenancy
Tenant and database isolation
List collections
Deleting documents
Delete by IDs
Delete by filter
Deleting collections
Converting results
To Haystack Documents
Score conversion
Chroma returns distances (0-2 for cosine). VectorDB converts to similarity scores:Metadata flattening
Chroma requires flat metadata. Nested structures are automatically flattened:Best practices
Use persistent client for development
Use persistent client for development
Persistent storage survives process restarts:
Metadata design for filtering
Metadata design for filtering
Keep metadata flat and scalar for optimal filtering:
Tenant isolation strategy
Tenant isolation strategy
Use tenant/database scoping for multi-tenancy:
Collection management
Collection management
Use
get_or_create=True for idempotent collection creation:Limitations
Empty metadata handling
Chroma 1.4+ requires non-empty metadata or None:Hybrid search availability
Hybrid search requires:- Chroma 0.6.0+
- Hosted/cloud environment
- Falls back to standard query on local instances
Scalar metadata only
Complex types are converted to strings:Error handling
Source reference
Implementation:src/vectordb/databases/chroma.py
Key classes and methods:
ChromaVectorDB.__init__(): src/vectordb/databases/chroma.py:75create_collection(): src/vectordb/databases/chroma.py:220upsert(): src/vectordb/databases/chroma.py:269query(): src/vectordb/databases/chroma.py:329search(): src/vectordb/databases/chroma.py:435flatten_metadata(): src/vectordb/databases/chroma.py:593