Skip to content

feat(search): the query language's parser - #334

Merged
leemour merged 1 commit into
mainfrom
feat/search-query
Oct 1, 2026
Merged

leemour merged 1 commit into
mainfrom
feat/search-query

Conversation

@leemour

@leemour leemour commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Task

Phase 2, item 4: src/search/query.ts, a pure function from the string to a tree, with the errors of §4.

Why

The search service (item 6) and messages search (item 7) take one string with operators. Parsing it apart from the search keeps every rule testable on its own.

What

  • parseQuery(query, { now }) → { required: Term[][], excluded, from?, chat?, after?, before?, has[], in? }. required is AND of OR-groups; words stay as typed.
  • Filters are case-insensitive. Only from chat after before has in are filters, so https://…, 12:30 and to:me are text.
  • after:/before: take a local day (2026-01-31) or days back (7d). after: is inclusive, before: exclusive.
  • has: may repeat; every other filter appears at most once.
  • Nothing calls it yet, and it is not exported.

Testing

src/search/query.test.ts: 18 cases — every operator, OR precedence, links and times as text, filters alone, and each refusal with its message. lint, typecheck, test:coverage (693), docs:check.


Reviewed against the review checklist — §B for code.

🤖 Generated with Claude Code

Phase 2, item 4: a pure function from the search string to a tree —
every word required, "phrases", -word and -"phrase" left out, OR binding
tighter than the implied AND, and the six filters from: chat: after:
before: has: in:. after: and before: take a local day or a count of days
back. Only those six names are filters, so a link or a time stays text.

It refuses, before anything is searched: only negations, OR without a
word on a side or beside a left-out word, a filter given twice, a day
that is not one, an unknown in: source, an empty value. Nothing calls it
yet; the search service (item 6) will.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@leemour
leemour merged commit 2273ba2 into main Oct 1, 2026
6 checks passed
@leemour
leemour deleted the feat/search-query branch October 1, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant