Text Search

Search text fields using the find operator. Performs substring matching with optional transforms for case-insensitive and whitespace-tolerant searching. Essential for search bars, autocomplete, and text filtering.

Syntax

Parameters

ParameterTypeRequiredDescription
attributestring Yes The text field to search in
operator'find' Yes The find operator for substring matching
valuestring Yes The search term (matches as substring)
options.transform('lowercase' | 'trim' | 'removeWhitespace')[] No Transform both data and search value before comparison
options.invertboolean No Exclude matches (find items NOT containing the term)
options.arrayValueHandling'some' | 'every' No For array fields: 'some' (any element) or 'every' (all elements)

Return Type

Returns void. Call items() to get matching results.

Usage Notes

  • The find operator performs substring matching (contains)
  • Always use transform: ['lowercase'] for user-facing search
  • Transforms apply to BOTH the data value AND your search term
  • Use multiple find conditions on same field for OR logic
  • Combine with other operators (eq, gte) for filtered search
  • For suggestions/autocomplete, see catalog.fn.suggest()

Related Methods

  • catalog.fn.suggest() - Get search suggestions with relevance
  • Query Filter - Exact match filtering with eq operator
  • Query Results - Get results with pagination

Examples

Search with Whitespace Handling

Handle inconsistent spacing in data with trim and removeWhitespace.

Combined Transforms

Apply multiple transforms for robust user search.

Search Multiple Fields

Search across name AND description fields.

Exclude Search Terms

Find products NOT containing "refurbished" using invert.

Search in Array Fields

Find products where ANY tag contains the search term.

Search with Category Filter

Combine text search with other filters.