Intro
Copy these minimal patterns and adapt fields to your models. Preferdry_run! and explain to debug locally without network I/O.
Index of patterns
- Exact match
- Prefix/infix match
- Any of list (IN)
- Price range + sort
- Pagination
- Facet filters
- Faceting DSL
- Pinned/hidden curation
- Grouping top‑N
- Joins — basic
- Multi‑search two relations
Recipes
Exact match
Small set lookup by ID.- Simple
Eqpredicate; validated field name - Use arrays for
IN(see below) - Links: Query DSL → Builders
Prefix/infix match
Begins‑with or contains‑like filters via templates/raw.PREFIXis parsed to AST; infix shown as raw Typesense fragment- Consider query text in
qfor full‑text; this is a filter - Links: Query DSL, Compiler
Any of list (IN)
Match any of several brands.- Non‑empty arrays only; values coerced per attribute type
- Links: Query DSL → Parsing examples
Price range + sort
Use two comparators for numeric ranges.- Typesense has no range literal in
filter_by; use>=and<= - Links: Compiler → Quoting & types
Pagination
Classic page/per; prefer this overlimit/offset unless you need offset math.
page >= 1,per >= 1; wins overlimit/offset- Links: Relation → order/select/pagination
Facet filters
Combine multiple filters with AND semantics across calls.- Each
whereappends; compiled withAND - Links: Query DSL → Where it fits
Pinned/hidden curation
Pin two IDs and hide one; keep network‑safe while inspecting.- Curation keys are body‑only; redacted in logs
- Hide wins when an ID is both pinned and hidden
- Links: Curation, Observability
Grouping top‑N
First hit per group, up to N hits inside each.group_limitcaps hits per group; pagination applies to number of groups- Links: Grouping
Joins — basic
Filter on a joined collection field.Multi‑search two relations
Send two labeled relations in one round‑trip.- Per‑search params compiled independently; order preserved by labels
- Links: Multi‑search
Debug each recipe
Useexplain or dry_run! to preview without I/O:
Edge‑case callouts
- Quoting: strings double‑quoted; booleans and
nullliteral; arrays flattened one level - Boolean coercion: only for boolean‑typed fields; strings “true”/“false” accepted
- Empty arrays: invalid for membership; provide at least one value
- Reserved characters: prefer templates with placeholders to avoid manual escaping
- Ambiguous names: unknown fields raise with suggestions when attributes are declared
- Sort vs group order: sort applies before grouping; group order preserved
Related links: Query DSL, Compiler, DX, Observability, Joins, Grouping, Presets, Curation