Kantoor. Search
(Kantoor v1.0.0)
Mailbox search over sender/recipient names and addresses, subject and indexed body text. Webmail matches every query word as a prefix, ignoring case, accents and quotes. Other punctuation separates words; input is never query syntax.
search_vector_v2 is maintained by a database trigger for every insert/update
of the source fields. Old rows use the same expression until Search.Backfill
has filled the column in small batches. The original body/subject index remains
available to IMAP TEXT/BODY with its existing whole-word semantics.
Only the caller's own, visible mail is searched: the mailbox is authorized with
Kantoor.Accounts.can_access_mailbox?/2 and held/expunged mail never matches.
Summary
Functions
Trims and caps a user query.
Searches mailbox for query. Options: :limit (default 50, max 200).
Returns {:ok, messages} ranked by relevance then recency, or
{:error, :not_found} when the mailbox is not the scope's.
An Ecto dynamic matching messages whose full-text vector contains every word of
text (used by IMAP SEARCH TEXT/BODY). Uses the original body/subject index
and simple configuration; matching is by word, not by substring.
The webmail search condition, shared with whole-result bulk selections.
Functions
Trims and caps a user query.
@spec search( Kantoor.Accounts.Scope.t(), Kantoor.Mailboxes.Mailbox.t(), String.t(), keyword() ) :: {:ok, [Kantoor.Mailboxes.Message.t()]} | {:error, :not_found}
Searches mailbox for query. Options: :limit (default 50, max 200).
Returns {:ok, messages} ranked by relevance then recency, or
{:error, :not_found} when the mailbox is not the scope's.
@spec text_condition(String.t()) :: Ecto.Query.dynamic_expr()
An Ecto dynamic matching messages whose full-text vector contains every word of
text (used by IMAP SEARCH TEXT/BODY). Uses the original body/subject index
and simple configuration; matching is by word, not by substring.
The webmail search condition, shared with whole-result bulk selections.