Pagination & Field Selection
Control how many results to return and which fields to include in your search results.Pagination with Limit
Uselimit() to control how many results to return and offset to skip results for pagination.
Limit Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | int or None | None | Maximum results to return (None = no limit) |
offset | int | 0 | Number of results to skip (for pagination) |
For Chroma Cloud users: The actual number of results returned will be capped by your quota limits, regardless of the
limit value specified. This applies even when no limit is set.Pagination Patterns
Pagination uses 0-based indexing. The first page is page 0, not page 1.
Field Selection with Select
Control which fields are returned in your results to optimize data transfer and processing.Selectable Fields
| Field | Internal Key | Usage | Description |
|---|---|---|---|
| IDs | #id | Always included | Document IDs are always returned |
K.DOCUMENT | #document | .select(K.DOCUMENT) | Full document text |
K.EMBEDDING | #embedding | .select(K.EMBEDDING) | Vector embeddings |
K.METADATA | #metadata | .select(K.METADATA) | All metadata fields as a dict |
K.SCORE | #score | .select(K.SCORE) | Search scores (when ranking is used) |
"field_name" | (user-defined) | .select("title", "author") | Specific metadata fields |
Field constants:
K.* constants (e.g., K.DOCUMENT, K.EMBEDDING, K.ID) correspond to internal keys with # prefix (e.g., #document, #embedding, #id). Use the K.* constants in queries. Internal keys like #document and #embedding are used in schema configuration, while #metadata and #score are query-only fields not used in schema.When selecting specific metadata fields (e.g., “title”), they appear directly in the metadata dict. Using K.METADATA returns ALL metadata fields at once.Performance Considerations
Selecting fewer fields improves performance by reducing data transfer:- Minimal: IDs only (default) - fastest queries
- Moderate: Add scores and specific metadata fields
- Heavy: Including documents and embeddings - larger payloads
- Maximum:
select_all()- returns everything
Edge Cases
No Limit Specified
Without a limit, the search attempts to return all matching results, but will be capped by quota limits in Chroma Cloud.Empty Results
When no documents match, results will have empty lists/arrays.Non-existent Fields
Selecting non-existent metadata fields simply omits them from the results - they won’t appear in the metadata dict.Complete Example
Here’s a practical example combining pagination with field selection:Tips and Best Practices
- Select only what you need - Reduces network transfer and memory usage
- Use appropriate page sizes - 10-50 for UI, 100-500 for batch processing
- Consider bandwidth - Avoid selecting embeddings unless necessary
- IDs are always included - No need to explicitly select them
- Use
select_all()sparingly - Only when you truly need all fields
Next Steps
- Learn about Group By & Aggregation to diversify search results by category
- Learn about batch operations for running multiple searches
- See practical examples of pagination in production
- Explore search basics for building complete queries