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
| Parameter | Type | Required | Description |
|---|---|---|---|
attribute | string | Yes | The text field to search in |
operator | 'find' | Yes | The find operator for substring matching |
value | string | Yes | The search term (matches as substring) |
options.transform | ('lowercase' | 'trim' | 'removeWhitespace')[] | No | Transform both data and search value before comparison |
options.invert | boolean | 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 relevanceQuery Filter- Exact match filtering with eq operatorQuery Results- Get results with pagination
Examples
Basic Text Search
Find products containing "bike" in the name (case-sensitive by default).
Case-Insensitive Search
Search ignoring case using lowercase transform (recommended for user input).
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.