1 <h1>NOTMUCH-SEARCH-TERMS(7)</h1>
5 notmuch-search-terms - syntax for notmuch queries
10 <b>notmuch</b> <b>count</b> [<u>options...</u>] <<u>search-term</u>>...
12 <b>notmuch</b> <b>dump</b> [ <<u>filename</u>> ] [--] [ <<u>search-term</u>>...]
14 <b>notmuch</b> <b>search</b> [<u>options</u>...] <<u>search-term</u>>...
16 <b>notmuch</b> <b>show</b> [<u>options</u>...] <<u>search-term</u>>...
18 <b>notmuch</b> <b>tag</b> +<<u>tag</u>>|-<<u>tag</u>> [...] [--] <<u>search-term</u>>...
23 Several notmuch commands accept a common syntax for search terms.
25 The search terms can consist of free-form text (and quoted phrases)
26 which will match all messages that contain all of the given
27 terms/phrases in the body, the subject, or any of the sender or recipi-
30 As a special case, a search string consisting of exactly a single
31 asterisk ("*") will match all messages.
33 In addition to free text, the following prefixes can be used to force
34 terms to match against specific portions of an email, (where <brackets>
35 indicate user-supplied values):
37 from:<name-or-address>
39 to:<name-or-address>
41 subject:<word-or-quoted-phrase>
43 attachment:<word>
45 tag:<tag> (or is:<tag>)
49 thread:<thread-id>
51 folder:<directory-path>
53 date:<since>..<until>
55 The <b>from:</b> prefix is used to match the name or address of the sender of
58 The <b>to:</b> prefix is used to match the names or addresses of any recipient
59 of an email message, (whether To, Cc, or Bcc).
61 Any term prefixed with <b>subject:</b> will match only text from the subject
62 of an email. Searching for a phrase in the subject is supported by
63 including quotation marks around the phrase, immediately following <b>sub-</b>
66 The <b>attachment:</b> prefix can be used to search for specific filenames (or
67 extensions) of attachments to email messages.
69 For <b>tag:</b> and <b>is:</b> valid tag values include <b>inbox</b> and <b>unread</b> by default
70 for new messages added by <b>notmuch</b> <b>new</b> as well as any other tag values
71 added manually with <b>notmuch</b> <b>tag</b>.
73 For <b>id:</b>, message ID values are the literal contents of the Message-ID:
74 header of email messages, but without the '<', '>' delimiters.
76 The <b>thread:</b> prefix can be used with the thread ID values that are gen-
77 erated internally by notmuch (and do not appear in email messages).
78 These thread ID values can be seen in the first column of output from
79 <b>notmuch</b> <b>search</b>
81 The <b>folder:</b> prefix can be used to search for email message files that
82 are contained within particular directories within the mail store. If
83 the same email message has multiple message files associated with it,
84 it's sufficient for a match that at least one of the files is contained
85 within a matching directory. Only the directory components below the
86 top-level mail database path are available to be searched.
88 The <b>date:</b> prefix can be used to restrict the results to only messages
89 within a particular time range (based on the Date: header) with a range
92 date:<since>..<until>
94 See <b>DATE</b> <b>AND</b> <b>TIME</b> <b>SEARCH</b> below for details on the range expression, and
95 supported syntax for <since> and <until> date and time expressions.
97 The time range can also be specified using timestamps with a syntax of:
99 <initial-timestamp>..<final-timestamp>
101 Each timestamp is a number representing the number of seconds since
102 1970-01-01 00:00:00 UTC.
104 In addition to individual terms, multiple terms can be combined with
105 Boolean operators ( <b>and</b>, <b>or</b>, <b>not</b> , etc.). Each term in the query will
106 be implicitly connected by a logical AND if no explicit operator is
107 provided, (except that terms with a common prefix will be implicitly
108 combined with OR until we get Xapian defect #402 fixed).
110 Parentheses can also be used to control the combination of the Boolean
111 operators, but will have to be protected from interpretation by the
112 shell, (such as by putting quotation marks around any parenthesized
116 <h2>DATE AND TIME SEARCH</h2>
118 notmuch understands a variety of standard and natural ways of express-
119 ing dates and times, both in absolute terms ("2012-10-24") and in rela-
120 tive terms ("yesterday"). Any number of relative terms can be combined
121 ("1 hour 25 minutes") and an absolute date/time can be combined with
122 relative terms to further adjust it. A non-exhaustive description of
123 the syntax supported for absolute and relative terms is given below.
125 <b>The</b> <b>range</b> <b>expression</b>
127 date:<since>..<until>
129 The above expression restricts the results to only messages
130 from <since> to <until>, based on the Date: header.
132 <since> and <until> can describe imprecise times, such as
133 "yesterday". In this case, <since> is taken as the earliest
134 time it could describe (the beginning of yesterday) and <until>
135 is taken as the latest time it could describe (the end of yes-
136 terday). Similarly, date:january..february matches from the
137 beginning of January to the end of February.
139 Currently, we do not support spaces in range expressions. You
140 can replace the spaces with '_', or (in most cases) '-', or (in
141 some cases) leave the spaces out altogether. Examples in this
142 man page use spaces for clarity.
144 Open-ended ranges are supported (since Xapian 1.2.1), i.e. it's
145 possible to specify date:..<until> or date:<since>.. to not
146 limit the start or end time, respectively. Pre-1.2.1 Xapian
147 does not report an error on open ended ranges, but it does not
148 work as expected either.
150 Entering date:expr without ".." (for example date:yesterday)
151 won't work, as it's not interpreted as a range expression at
152 all. You can achieve the expected result by duplicating the
153 expr both sides of ".." (for example date:yesterday..yester-
156 <b>Relative</b> <b>date</b> <b>and</b> <b>time</b>
157 [N|number] (years|months|weeks|days|hours|hrs|minutes|mins|sec-
160 All refer to past, can be repeated and will be accumulated.
162 Units can be abbreviated to any length, with the otherwise
163 ambiguous single m being m for minutes and M for months.
165 Number can also be written out one, two, ..., ten, dozen, hun-
166 dred. Additionally, the unit may be preceded by "last" or
167 "this" (e.g., "last week" or "this month").
169 When combined with absolute date and time, the relative date
170 and time specification will be relative from the specified
171 absolute date and time.
173 Examples: 5M2d, two weeks
175 <b>Supported</b> <b>absolute</b> <b>time</b> <b>formats</b>
176 H[H]:MM[:SS] [(am|a.m.|pm|p.m.)]
178 H[H] (am|a.m.|pm|p.m.)
190 <b>Supported</b> <b>absolute</b> <b>date</b> <b>formats</b>
203 D[D][(st|nd|rd|th)] Mon[thname] [YYYY]
205 Mon[thname] D[D][(st|nd|rd|th)] [YYYY]
209 Month names can be abbreviated at three or more characters.
211 Weekday names can be abbreviated at three or more characters.
213 Examples: 2012-07-31, 31-07-2012, 7/31/2012, August 3
215 <b>Time</b> <b>zones</b>
220 Some time zone codes, e.g. UTC, EET.
225 <a href='../notmuch-1/'>notmuch</a>(1), <a href='../notmuch-config-1/'>notmuch-config</a>(1), <a href='../notmuch-count-1/'>notmuch-count</a>(1), <a href='../notmuch-dump-1/'>notmuch-dump</a>(1), <a href='../notmuch-hooks-5/'>not-</a>
226 <a href='../notmuch-hooks-5/'>much-hooks</a>(5), <a href='../notmuch-insert-1/'>notmuch-insert</a>(1), <a href='../notmuch-new-1/'>notmuch-new</a>(1), <a href='../notmuch-reply-1/'>notmuch-reply</a>(1),
227 <a href='../notmuch-restore-1/'>notmuch-restore</a>(1), <a href='../notmuch-search-1/'>notmuch-search</a>(1), <a href='../notmuch-show-1/'>notmuch-show</a>(1), <a href='../notmuch-tag-1/'>notmuch-tag</a>(1)
230 <h2>Notmuch 0.17</h2>