DocsSearch
Query Language Reference
On this page
cass supports a rich query syntax designed for both humans and machines.
Basic Queries#
| Query | Matches |
|---|---|
error |
Messages containing "error" (case-insensitive) |
python error |
Messages containing both "python" AND "error" |
"authentication failed" |
Exact phrase match |
auth fail |
Both terms, in any order |
Boolean Operators#
Combine terms with explicit operators for complex queries:
| Operator | Example | Meaning |
|---|---|---|
AND |
python AND error |
Both terms required (default) |
OR |
error OR warning |
Either term matches |
NOT |
error NOT test |
First term, excluding second |
|
error |
Shorthand for NOT |
Operator Precedence: NOT binds tightest, then AND (explicit, &&, or implied between words), then OR (OR, ||). Parentheses group, in the TUI and robot mode alike: a OR b c means a OR (b AND c), while (a OR b) c needs the parentheses. A ( groups only at the start of a word, so code such as foo(bar) stays one term. NOT NOT x is x. Unbalanced parentheses are recovered rather than rejected. The SQLite fallback lanes, used while no lexical index is available, apply the same grammar.
Titles count as message text. Each message is matched together with its conversation's title, which is often the conversation's first prompt. A term that appears only in the title therefore matches every message of that conversation, and x NOT y drops every message of a conversation whose title contains y. For example, in a conversation titled fix auth tests, error NOT tests returns none of its messages.
# Complex boolean query
cass search "authentication AND (error OR failure) NOT test" --robot
# Exclude test files
cass search "bug fix -test -spec" --robot
# Either error type
cass search "TypeError OR ValueError" --robot
Phrase Queries#
Wrap terms in double quotes for exact phrase matching:
| Query | Matches |
|---|---|
"file not found" |
Exact sequence "file not found" |
"cannot read property" |
Exact JavaScript error message |
"def test_" |
Function definitions starting with test_ |
Phrases match their words adjacent and in order (no slop). Useful for error messages, code patterns, and specific terminology.
Wildcard Patterns#
| Pattern | Type | Matches | Performance |
|---|---|---|---|
auth* |
Prefix | "auth", "authentication", "authorize" | Fast (uses edge n-grams) |
*tion |
Suffix | "authentication", "function", "exception" | Slower (term-dictionary expansion) |
*config* |
Substring | "reconfigure", "config.json", "misconfigured" | Slowest (term-dictionary expansion) |
test_* |
Prefix on test |
anything whose token starts with "test" | Fast |
Tip: Ordinary ASCII prefix wildcards (foo*) retain the existing edge n-grams: prefixes of 2–20 characters, taken from titles and from the first 4 KiB of each message. Suffix and substring wildcards expand over the index's term dictionary, at most 16,384 terms per pattern; a pattern matching more terms fails rather than scanning. ASCII punctuation separates terms: test_* is a prefix match on test, c++ searches for c, and foo.bar means foo AND bar anywhere in the message. Phrases ("...") match adjacent words in order (slop 0).
Lexical indexing recognizes Unicode alphanumeric words, including Cyrillic,
Greek, Arabic, Hebrew and accented Latin. Case is normalized with Unicode
lowercasing: сервер and СЕРВЕР find the same word, and серв* finds its
prefix. Hyphenated words retain both the compound and its parts. CJK text keeps
the existing overlapping bigrams.
Unicode words remain whole: "kérlek" matches the exact word rather than the
unrelated adjacent ASCII fragments k rlek. Bare words of 2–20 Unicode scalars
retain the existing implicit final-token prefix: kérlek also matches
kérleknek, while "kérlek" does not. Explicit Unicode prefixes such as
kérl* and серв* search the full term dictionary, including text beyond the
first 4 KiB and prefixes longer than 20 characters. They allow up to 1,024
matching terms per field and immutable index segment; exceeding that budget
returns an error instead of a partial result. café* keeps the accent and
does not match cafeteria. Unicode suffix, substring and interior wildcards
are supported within a single word, for example *сервер, *серв* and се*вер.
The Unicode schema requires rebuilding older ASCII-only lexical postings:
cass index --full
CASS preserves the directory and document identities; the new schema
fingerprint rejects old postings and the rebuild uses the canonical archive.
Words are limited to 256 UTF-8 source bytes before lowercasing, which can expand
the normalized text. This is Unicode lowercase matching, not Unicode
normalization or full case folding. Non-alphanumeric combining marks remain
separators, so canonically equivalent spellings can still produce different
terms. Mixed CJK queries require the analyzer's actual terms in one field, with
the existing conjunction behavior for overlapping bigrams. An operand with no
indexed terms, including an oversized source word, refuses the whole nonempty
query under OR and NOT; it cannot become an empty browse query. A quoted
phrase ignores edge stars under the existing syntax but rejects interior stars.
Query Modifiers#
# Field-specific search (in robot mode)
cass search "error" --agent claude --workspace /path/to/project
# Time-bounded search
cass search "bug" --since 2024-01-01 --until 2024-01-31
cass search "bug" --today
cass search "bug" --days 7
# Combined filters
cass search "authentication" --agent codex --workspace myproject --week
Flexible Time Input#
cass accepts a wide variety of time/date formats for filtering:
| Format | Examples | Description |
|---|---|---|
| Relative | , , , |
Days, hours, minutes, weeks ago |
| Keywords | now, today, yesterday |
Named reference points |
| ISO 8601 | , |
Standard datetime |
| US Dates | 11/25/2024, |
Month/Day/Year |
| Unix Timestamp | 1732579200, |
Seconds since epoch (negative before 1970) |
| Unix Millis | 1732579200000, |
Milliseconds (auto-detected) |
Intelligent Heuristics:
- Numbers whose absolute value is 100,000,000,000 (10^11) or more are milliseconds; smaller magnitudes are seconds
- Years are written in full (
2024, not24) - A value that names a whole day (a date without a time,
today,yesterday) starts at local midnight asand runs through the day's last millisecond as--since , so--until includes January 31--until 2024-01-31 - For
searchandpack, a/--since value that cannot be parsed, or a--until later than--since , is a usage error (exit 2, kind--until usage); it is never silently ignored
# All equivalent for "last week"
cass search "bug" --since -7d
cass search "bug" --since "-1w"
cass search "bug" --days 7
# Date range
cass search "feature" --since 2024-01-01 --until 2024-01-31
# Mix formats
cass search "error" --since yesterday --until now
Match Types#
Search results include a match_type indicator. It describes the query, not each hit: every hit of a search carries the type of the least precise pattern in the query (e.g. auth* *tion stamps suffix on all hits).
| Type | Meaning | Match Quality order |
|---|---|---|
exact |
No wildcards: exact terms (and edge n-gram prefixes) | 1 |
prefix |
Trailing wildcard (auth*) |
2 |
suffix |
Leading wildcard (*tion) |
3 |
substring |
Both sides (*config*) |
4 |
wildcard |
Inner wildcard (f*o) |
5 |
implicit_wildcard |
Automatic wildcard fallback on a sparse exact search | 6 |
Relevance scores carry no boost for the match type; only the TUI's Match Quality ranking mode (F12) orders by it.
Auto-Fuzzy Fallback#
When an exact query's first page returns fewer than 3 results (or fewer than a smaller ), cass retries with wildcard expansion:
auth→*auth*- It runs only on indexes with at most 10,000 documents (
CASS_AUTOMATIC_WILDCARD_FALLBACK_MAX_DOCS;0disables it), so on a typical real archive it does not run. - It skips queries that already use wildcards, boolean operators or phrases, and zero-hit queries containing a token longer than 16 characters.
- The wildcard results replace the exact ones only when they find more hits; robot mode then reports
_meta.wildcard_fallback: true. When a sparse result did not get the retry,_meta.wildcard_fallback_skippedsays why:index_over_automatic_limit(the index is over the document cap),automatic_retry_disabled(the cap is0) orlong_query_term; add explicit wildcards to run it anyway. When the retry itself runs out of query fuel, the exact results are returned and the field isquery_fuel_exhausted - TUI shows a "fuzzy" indicator in the status bar