Skip to main content

Pagination with Limit

Use limit() to control how many results to return and offset to skip results for pagination.

Limit Parameters

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 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