.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "NOTMUCH-SEARCH-TERMS" "7" "Oct 03, 2024" "0.38.3" "notmuch" .SH NAME notmuch-search-terms \- syntax for notmuch queries .SH SYNOPSIS .sp \fBnotmuch\fP \fBcount\fP [option ...] <\fIsearch\-term\fP> ... .sp \fBnotmuch\fP \fBdump\fP [\-\-gzip] [\-\-format=(batch\-tag|sup)] [\-\-output=<\fIfile\fP>] [\-\-] [<\fIsearch\-term\fP> ...] .sp \fBnotmuch\fP \fBreindex\fP [option ...] <\fIsearch\-term\fP> ... .sp \fBnotmuch\fP \fBsearch\fP [option ...] <\fIsearch\-term\fP> ... .sp \fBnotmuch\fP \fBshow\fP [option ...] <\fIsearch\-term\fP> ... .sp \fBnotmuch\fP \fBtag\fP +<\fItag\fP> ... \-<\fItag\fP> [\-\-] <\fIsearch\-term\fP> ... .SH DESCRIPTION .sp Several notmuch commands accept a common syntax for search terms. .sp The search terms can consist of free\-form text (and quoted phrases) which will match all messages that contain all of the given terms/phrases in the body, the subject, or any of the sender or recipient headers. .sp As a special case, a search string consisting of exactly a single asterisk (\(dq*\(dq) will match all messages. .SS Search prefixes .sp In addition to free text, the following prefixes can be used to force terms to match against specific portions of an email, (where indicate user\-supplied values). .sp Some of the prefixes with forms can be also used to restrict the results to those whose value matches a regular expression (see \fB\X'tty: link https://manpages.debian.org/regex.7.html'\fI\%regex(7)\fP\X'tty: link'\fP) delimited with //, for example: .INDENT 0.0 .INDENT 3.5 .sp .EX notmuch search \(aqfrom:\(dq/bob@.*[.]example[.]com/\(dq\(aq .EE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B body: Match terms in the body of messages. .TP .B from: or from:// The \fBfrom:\fP prefix is used to match the name or address of the sender of an email message. .TP .B to: The \fBto:\fP prefix is used to match the names or addresses of any recipient of an email message, (whether To, Cc, or Bcc). .TP .B subject: or subject:// Any term prefixed with \fBsubject:\fP will match only text from the subject of an email. Searching for a phrase in the subject is supported by including quotation marks around the phrase, immediately following \fBsubject:\fP\&. .TP .B attachment: The \fBattachment:\fP prefix can be used to search for specific filenames (or extensions) of attachments to email messages. .TP .B mimetype: The \fBmimetype:\fP prefix will be used to match text from the content\-types of MIME parts within email messages (as specified by the sender). .TP .B tag: or tag:// or is: or is:// For \fBtag:\fP and \fBis:\fP valid tag values include \fBinbox\fP and \fBunread\fP by default for new messages added by \fI\%notmuch\-new\fP as well as any other tag values added manually with \fI\%notmuch\-tag\fP\&. .TP .B id: or mid: or mid:// For \fBid:\fP and \fBmid:\fP, message ID values are the literal contents of the Message\-ID: header of email messages, but without the \(aq<\(aq, \(aq>\(aq delimiters. .TP .B thread: The \fBthread:\fP prefix can be used with the thread ID values that are generated internally by notmuch (and do not appear in email messages). These thread ID values can be seen in the first column of output from \fI\%notmuch\-search\fP .TP .B thread:{} Threads may be searched for indirectly by providing an arbitrary notmuch query in \fB{}\fP\&. For example, the following returns threads containing a message from mallory and one (not necessarily the same message) with Subject containing the word \(dqcrypto\(dq. .INDENT 7.0 .INDENT 3.5 .sp .EX % notmuch search \(aqthread:\(dq{from:mallory}\(dq and thread:\(dq{subject:crypto}\(dq\(aq .EE .UNINDENT .UNINDENT .sp The performance of such queries can vary wildly. To understand this, the user should think of the query \fBthread:{}\fP as expanding to all of the thread IDs which match \fB\fP; notmuch then performs a second search using the expanded query. .TP .B path: or path:/** or path:// The \fBpath:\fP prefix searches for email messages that are in particular directories within the mail store. The directory must be specified relative to the top\-level maildir (and without the leading slash). By default, \fBpath:\fP matches messages in the specified directory only. The \(dq/**\(dq suffix can be used to match messages in the specified directory and all its subdirectories recursively. \fBpath:\(dq\(dq\fP matches messages in the root of the mail store and, likewise, \fBpath:**\fP matches all messages. .sp \fBpath:\fP will find a message if \fIany\fP copy of that message is in the specific directory. .TP .B folder: or folder:// The \fBfolder:\fP prefix searches for email messages by maildir or MH folder. For MH\-style folders, this is equivalent to \fBpath:\fP\&. For maildir, this includes messages in the \(dqnew\(dq and \(dqcur\(dq subdirectories. The exact syntax for maildir folders depends on your mail configuration. For maildir++, \fBfolder:\(dq\(dq\fP matches the inbox folder (which is the root in maildir++), other folder names always start with \(dq.\(dq, and nested folders are separated by \(dq.\(dqs, such as \fBfolder:.classes.topology\fP\&. For \(dqfile system\(dq maildir, the inbox is typically \fBfolder:INBOX\fP and nested folders are separated by slashes, such as \fBfolder:classes/topology\fP\&. .sp \fBfolder:\fP will find a message if \fIany\fP copy of that message is in the specific folder. .TP .B date:.. or date: The \fBdate:\fP prefix can be used to restrict the results to only messages within a particular time range (based on the Date: header). .sp See \fBDATE AND TIME SEARCH\fP below for details on the range expression, and supported syntax for and date and time expressions. .sp The time range can also be specified using timestamps without including the date prefix using a syntax of: .sp .. .sp Each timestamp is a number representing the number of seconds since 1970\-01\-01 00:00:00 UTC. Specifying a time range this way is considered legacy and predates the date prefix. .TP .B lastmod:.. The \fBlastmod:\fP prefix can be used to restrict the result by the database revision number of when messages were last modified (tags were added/removed or filenames changed). Negative revisions are interpreted relative to the most recent database revision (see \fI\%count \-\-lastmod\fP). This is usually used in conjunction with the \fB\-\-uuid\fP argument to \fI\%notmuch\-search\fP to find messages that have changed since an earlier query. .TP .B query: The \fBquery:\fP prefix allows queries to refer to previously saved queries added with \fI\%notmuch\-config\fP\&. .TP .B property:= The \fBproperty:\fP prefix searches for messages with a particular = property pair. Properties are used internally by notmuch (and extensions) to add metadata to messages. A given key can be present on a given message with several different values. See \fI\%notmuch\-properties\fP for more details. .TP .B sexp: The \fBsexp:\fP prefix allows subqueries in the format documented in \fI\%notmuch\-sexp\-queries\fP\&. Note that subqueries containing spaces must be quoted, and any embedded double quotes must be escaped (see \fI\%Quoting\fP). .UNINDENT .sp User defined prefixes are also supported, see \fI\%notmuch\-config\fP for details. .SS Operators .sp In addition to individual terms, multiple terms can be combined with Boolean operators (\fBand\fP, \fBor\fP, \fBnot\fP, and \fBxor\fP). Each term in the query will be implicitly connected by a logical AND if no explicit operator is provided (except that terms with a common prefix will be implicitly combined with OR). The shorthand \(aq\-\(aq can be used for \(aqnot \(aq but unfortunately this does not work at the start of an expression. Parentheses can also be used to control the combination of the Boolean operators, but will have to be protected from interpretation by the shell, (such as by putting quotation marks around any parenthesized expression). .sp In addition to the standard boolean operators, Xapian provides several operators specific to text searching. .INDENT 0.0 .INDENT 3.5 .sp .EX notmuch search term1 NEAR term2 .EE .UNINDENT .UNINDENT .sp will return results where term1 is within 10 words of term2. The threshold can be set like this: .INDENT 0.0 .INDENT 3.5 .sp .EX notmuch search term1 NEAR/2 term2 .EE .UNINDENT .UNINDENT .sp The search .INDENT 0.0 .INDENT 3.5 .sp .EX notmuch search term1 ADJ term2 .EE .UNINDENT .UNINDENT .sp will return results where term1 is within 10 words of term2, but in the same order as in the query. The threshold can be set the same as with NEAR: .INDENT 0.0 .INDENT 3.5 .sp .EX notmuch search term1 ADJ/7 term2 .EE .UNINDENT .UNINDENT .SS Stemming .sp \fBStemming\fP in notmuch means that these searches .INDENT 0.0 .INDENT 3.5 .sp .EX notmuch search detailed notmuch search details notmuch search detail .EE .UNINDENT .UNINDENT .sp will all return identical results, because Xapian first \(dqreduces\(dq the term to the common stem (here \(aqdetail\(aq) and then performs the search. .sp There are two ways to turn this off: a search for a capitalized word will be performed unstemmed, so that one can search for \(dqJohn\(dq and not get results for \(dqJohnson\(dq; phrase searches are also unstemmed (see below for details). Stemming is currently only supported for English. Searches for words in other languages will be performed unstemmed. .SS Wildcards .sp It is possible to use a trailing \(aq*\(aq as a wildcard. A search for \(aqwildc*\(aq will match \(aqwildcard\(aq, \(aqwildcat\(aq, etc. .SS Boolean and Probabilistic Prefixes .sp Xapian (and hence notmuch) prefixes are either \fBboolean\fP, supporting exact matches like \(dq\fI\%tag:inbox\fP\(dq or \fBprobabilistic\fP, supporting a more flexible \fBterm\fP based searching. Certain \fBspecial\fP prefixes are processed by notmuch in a way not strictly fitting either of Xapian\(aqs built in styles. The prefixes currently supported by notmuch are as follows. .INDENT 0.0 .TP .B Boolean \fBtag:\fP, \fBid:\fP, \fBthread:\fP, \fBfolder:\fP, \fBpath:\fP, \fBproperty:\fP .TP .B Probabilistic \fBbody:\fP, \fBto:\fP, \fBattachment:\fP, \fBmimetype:\fP .TP .B Special \fBfrom:\fP, \fBquery:\fP, \fBsubject:\fP, \fBsexp:\fP .UNINDENT .SS Terms and phrases .sp In general Xapian distinguishes between lists of terms and \fBphrases\fP\&. Phrases are indicated by double quotes (but beware you probably need to protect those from your shell) and insist that those unstemmed words occur in that order. One useful, but initially surprising feature is that the following are equivalent ways to write the same phrase. .INDENT 0.0 .IP \(bu 2 \(dqa list of words\(dq .IP \(bu 2 a\-list\-of\-words .IP \(bu 2 a/list/of/words .IP \(bu 2 a.list.of.words .UNINDENT .sp Both parenthesised lists of terms and quoted phrases are ok with probabilistic prefixes such as \fBto:\fP, \fBfrom:\fP, and \fBsubject:\fP\&. For prefixes supporting regex search, the parenthesised list should be quoted. In particular .INDENT 0.0 .INDENT 3.5 .sp .EX subject:\(dq(pizza free)\(dq .EE .UNINDENT .UNINDENT .sp is equivalent to .INDENT 0.0 .INDENT 3.5 .sp .EX subject:pizza and subject:free .EE .UNINDENT .UNINDENT .sp Both of these will match a subject \(dqFree Delicious Pizza\(dq while .INDENT 0.0 .INDENT 3.5 .sp .EX subject:\(dqpizza free\(dq .EE .UNINDENT .UNINDENT .sp will not. .SS Quoting .sp Double quotes are also used by the notmuch query parser to protect boolean terms, regular expressions, or subqueries containing spaces or other special characters, e.g. .INDENT 0.0 .INDENT 3.5 .sp .EX tag:\(dqa tag\(dq .EE .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX folder:\(dq/^.*/(Junk|Spam)$/\(dq .EE .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX thread:\(dq{from:mallory and date:2009}\(dq .EE .UNINDENT .UNINDENT .sp As with phrases, you need to protect the double quotes from the shell e.g. .INDENT 0.0 .INDENT 3.5 .sp .EX % notmuch search \(aqfolder:\(dq/^.*/(Junk|Spam)$/\(dq\(aq % notmuch search \(aqthread:\(dq{from:mallory and date:2009}\(dq and thread:{to:mallory}\(aq .EE .UNINDENT .UNINDENT .sp Double quotes within query strings need to be doubled to escape them. .INDENT 0.0 .INDENT 3.5 .sp .EX % notmuch search \(aqtag:\(dq\(dq\(dqquoted tag\(dq\(dq\(dq\(aq % notmuch search \(aqsexp:\(dq(or \(dq\(dqwizard\(dq\(dq \(dq\(dqphp\(dq\(dq)\(dq\(aq .EE .UNINDENT .UNINDENT .SH DATE AND TIME SEARCH .sp notmuch understands a variety of standard and natural ways of expressing dates and times, both in absolute terms (\(dq2012\-10\-24\(dq) and in relative terms (\(dqyesterday\(dq). Any number of relative terms can be combined (\(dq1 hour 25 minutes\(dq) and an absolute date/time can be combined with relative terms to further adjust it. A non\-exhaustive description of the syntax supported for absolute and relative terms is given below. .SS The range expression .sp date:.. .sp The above expression restricts the results to only messages from to , based on the Date: header. .sp and can describe imprecise times, such as \(dqyesterday\(dq. In this case, is taken as the earliest time it could describe (the beginning of yesterday) and is taken as the latest time it could describe (the end of yesterday). Similarly, date:january..february matches from the beginning of January to the end of February. .sp If specifying a time range using timestamps in conjunction with the date prefix, each timestamp must be preceded by @ (ASCII hex 40). As above, each timestamp is a number representing the number of seconds since 1970\-01\-01 00:00:00 UTC. For example: .INDENT 0.0 .INDENT 3.5 date:@..@ .UNINDENT .UNINDENT .sp Currently, spaces in range expressions are not supported. You can replace the spaces with \(aq_\(aq, or (in most cases) \(aq\-\(aq, or (in some cases) leave the spaces out altogether. Examples in this man page use spaces for clarity. .sp Open\-ended ranges are supported. I.e. it\(aqs possible to specify date:.. or date:.. to not limit the start or end time, respectively. .SS Single expression .sp date: works as a shorthand for date:... For example, date:monday matches from the beginning of Monday until the end of Monday. .SS Relative date and time .sp [N|number] (years|months|weeks|days|hours|hrs|minutes|mins|seconds|secs) [...] .sp All refer to past, can be repeated and will be accumulated. .sp Units can be abbreviated to any length, with the otherwise ambiguous single m being m for minutes and M for months. .sp Number can also be written out one, two, ..., ten, dozen, hundred. Additionally, the unit may be preceded by \(dqlast\(dq or \(dqthis\(dq (e.g., \(dqlast week\(dq or \(dqthis month\(dq). .sp When combined with absolute date and time, the relative date and time specification will be relative from the specified absolute date and time. .sp Examples: 5M2d, two weeks .SS Supported absolute time formats .INDENT 0.0 .IP \(bu 2 H[H]:MM[:SS] [(am|a.m.|pm|p.m.)] .IP \(bu 2 H[H] (am|a.m.|pm|p.m.) .IP \(bu 2 HHMMSS .IP \(bu 2 now .IP \(bu 2 noon .IP \(bu 2 midnight .IP \(bu 2 Examples: 17:05, 5pm .UNINDENT .SS Supported absolute date formats .INDENT 0.0 .IP \(bu 2 YYYY\-MM[\-DD] .IP \(bu 2 DD\-MM[\-[YY]YY] .IP \(bu 2 MM\-YYYY .IP \(bu 2 M[M]/D[D][/[YY]YY] .IP \(bu 2 M[M]/YYYY .IP \(bu 2 D[D].M[M][.[YY]YY] .IP \(bu 2 D[D][(st|nd|rd|th)] Mon[thname] [YYYY] .IP \(bu 2 Mon[thname] D[D][(st|nd|rd|th)] [YYYY] .IP \(bu 2 Wee[kday] .UNINDENT .sp Month names can be abbreviated at three or more characters. .sp Weekday names can be abbreviated at three or more characters. .sp Examples: 2012\-07\-31, 31\-07\-2012, 7/31/2012, August 3 .SS Time zones .INDENT 0.0 .IP \(bu 2 (+|\-)HH:MM .IP \(bu 2 (+|\-)HH[MM] .UNINDENT .sp Some time zone codes, e.g. UTC, EET. .SH SEE ALSO .sp \fI\%notmuch\fP, \fI\%notmuch\-config\fP, \fI\%notmuch\-count\fP, \fI\%notmuch\-dump\fP, \fI\%notmuch\-hooks\fP, \fI\%notmuch\-insert\fP, \fI\%notmuch\-new\fP, \fI\%notmuch\-properties\fP, \fI\%notmuch\-reindex\fP, \fI\%notmuch\-reply\fP, \fI\%notmuch\-restore\fP, \fI\%notmuch\-search\fP, \fI\%notmuch\-show\fP, \fI\%notmuch\-tag\fP .SH AUTHOR Carl Worth and many others .SH COPYRIGHT 2009-2024, Carl Worth and many others .\" Generated by docutils manpage writer. .