Skip to main content
This page covers the basics of Search construction. For detailed usage of specific components, see:

The Search Class

Constructor Parameters

The Search class accepts four optional parameters:
  • where: Filter expressions to narrow down results
    • Types: Where expression, dict, or None
    • Default: None (no filtering)
  • rank: Ranking expressions to score and order results
    • Types: Rank expression, dict, or None
    • Default: None (no ranking, natural order)
  • limit: Pagination control
    • Types: Limit object, dict, int, or None
    • Default: None (no limit)
  • select: Fields to include in results
    • Types: Select object, dict, list, set, or None
    • Default: None (returns IDs only)
    • Available fields: #id, #document, #embedding, #metadata, #score, or any custom metadata field
    • See field selection for details

Builder Pattern

The Search class provides a fluent interface with method chaining. Each method returns a new Search instance, making queries immutable and safe to reuse. For detailed usage of each builder method, see the respective sections:
Benefits of immutability:
  • Base queries can be reused safely
  • No unexpected side effects from modifications
  • Easy to create query variations

Direct Construction

You can create Search objects directly with various parameter types:

Empty Search Behavior

An empty Search object has specific default behaviors:

Common Initialization Patterns

Here are common patterns for building Search queries:

Next Steps