todo: mark Gmail-style operators done; note OR/grouping as remaining
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -27,17 +27,15 @@ Deferred work. Context: Officer is collapsing from multi-tenant / open-source-re
|
|||||||
|
|
||||||
## Email
|
## Email
|
||||||
|
|
||||||
- [ ] **Gmail-style search operators.** Extend the FTS5 search (`/email/search`, `searchEmails` +
|
- [x] **Gmail-style search operators** (done 2026-07-24, `0e5b91e`). `parseEmailQuery` +
|
||||||
`toFtsQuery` in `api/email/email-db.ts`) to parse structured operators like `from:`, `to:`,
|
`searchEmails` in `api/email/email-db.ts` parse: `from:`/`to:`/`subject:`/`body:` → FTS5 column
|
||||||
`subject:`, `has:attachment`, `label:`, `before:`/`after:` (dates), `is:unread`, quoted phrases,
|
filters; `has:attachment`, `is:unread`/`is:read`, `label:X`, `before:`/`after:YYYY-MM-DD` → SQL
|
||||||
and `OR`. Today `toFtsQuery` just does per-term prefix-AND across all columns.
|
`WHERE` on `emails`; quoted values → exact phrases; free text → prefix-AND full-text; unknown
|
||||||
Approach: split the query into (a) **field-scoped text** → FTS5 column filters (the `emails_fts`
|
`op:val` falls back to free text. Structured-filters-only queries skip the FTS join. Validated
|
||||||
table already has named columns `subject`/`sender`/`recipients`/`snippet`/`body`, so
|
on the real 18k-mail DB. Search box placeholder hints at operators.
|
||||||
`subject:foo` → `{subject}:"foo"*` in the MATCH; `from:x` → the `sender` column) and (b)
|
- [ ] **Remaining:** `OR` and parenthesised grouping (currently everything is ANDed). Would need a
|
||||||
**structured filters** applied as SQL `WHERE` alongside the MATCH — `has:attachment` →
|
real boolean parser instead of the flat tokenizer. Also consider `in:sent/inbox/spam/trash`
|
||||||
`attachment_count > 0`, `before:/after:` → `date` range, `is:unread` → `read = 0`, `label:` →
|
(folder scope) and relative dates (`newer_than:7d`).
|
||||||
`labels LIKE`. Free text stays full-text. Frontend: keep the single search box (operators are
|
|
||||||
typed inline, Gmail-style) — no UI change needed beyond maybe a hint/legend.
|
|
||||||
|
|
||||||
## Known bugs
|
## Known bugs
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user