Documentation
¶
Overview ¶
Package search parses the search language (docs/specs/search.md) into a Query the store turns into SQL over messages and messages_fts. Parse is forgiving: anything it does not understand becomes a text term. Match and Exclude build the FTS5 expressions for the terms.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRelative ¶
ParseRelative reads Nd, Nw, Nm or Ny (N >= 1) as midnight in loc of the day N days, weeks, 30-day months or 365-day years before now's day in loc: newer_than: and older_than:, and the within and notwithin conditions (docs/design/organize.md).
func ToConditions ¶
func ToConditions(q Query, loc *time.Location) api.Conditions
ToConditions turns a parsed search into conditions that list the same messages (docs/design/organize.md, From a search), for Save as Smart Mailbox. Dates are days in loc; newer_than: and older_than: stay relative.
Types ¶
type Query ¶
type Query struct {
Terms []Term // full-text conditions, in input order
Unread *bool // is:unread / is:read
Flagged *bool // is:flagged / -is:flagged
HasAttachment *bool // has:attachment / -has:attachment
After time.Time // inclusive lower bound (zero: none)
Before time.Time // exclusive upper bound (zero: none)
Roles []api.MailboxRole // in:inbox, in:sent, … (any of them)
// AfterRel and BeforeRel are newer_than: and older_than:'s values
// ("2d") when After or Before came from one, so a saved search stays
// relative (ToConditions).
AfterRel, BeforeRel string
}
Query is a parsed search.
func Parse ¶
Parse reads the search language. It never fails: unknown or malformed operators become text terms.