Search API Overview
The Search API is a powerful, flexible interface for hybrid search operations in Chroma Cloud, combining vector similarity search with metadata filtering and custom ranking expressions.What is the Search API?
The Search API provides a powerful, unified interface for all search operations in Chroma. Instead of using separatequery() and get() methods with different parameters, the Search API offers:
- Unified interface: One consistent API replaces both
query()andget()methods - Expression-based queries: Use
K()expressions for powerful filtering and field selection - Composable operations: Chain methods to build complex queries naturally
- Type safety: Full type hints, IDE autocomplete, and clear error messages
- Advanced capabilities: Hybrid search with RRF, custom ranking expressions, and batch operations
- Flexible result selection: Choose exactly which fields to return, reducing payload size
Quick Start
When passing text to
Knn(), the embedding is automatically created using the collection’s schema configuration. By default, Knn uses the #embedding key, which corresponds to the default vector index. You can specify a different key with the key parameter (e.g., Knn(query=query_text, key="my_custom_embedding")). If the specified key doesn’t have an embedding configuration in the collection schema, an error will be thrown.Feature Comparison
| Feature | query() | get() | search() |
|---|---|---|---|
| Vector similarity search | Yes | No | Yes |
| Filtering (metadata, document, ID) | Yes | Yes | Yes |
| Custom ranking expressions | No | No | Yes |
| Result grouping/deduplication | No | No | Yes |
| Batch operations | Partial (Embedding only) | No | Yes |
| Field selection | Partial (Coarse) | Partial (Coarse) | Yes |
| Pagination | No | Yes | Yes |
| Type safety | Partial | Partial | Yes |
Availability
The Search API is available for Chroma Cloud. Support for local Chroma deployments will be available in a future release.Required Setup
To use the Search API, you’ll need to import the necessary components:Complete Example
Here’s a practical example searching for science articles:Performance
The Search API provides the same performance as existing Chroma query endpoints, with the added benefit of more flexible query construction and batch operations that can reduce the number of round trips.Feedback
Please report issues or feedback through the Chroma GitHub repository.
What’s Next?
- Search Basics - Learn how to construct searches
- Filtering with Where - Master metadata filtering
- Ranking and Scoring - Understand ranking expressions
- Group By & Aggregation - Diversify results with grouping
- Hybrid Search - Combine multiple strategies
- Examples - See real-world patterns