]> git.notmuchmail.org Git - notmuch/blob - man/man7/notmuch-search-terms.7
8916fdad6a3fb6503ff920e90fa5f82ca1148fba
[notmuch] / man / man7 / notmuch-search-terms.7
1 .TH NOTMUCH-SEARCH-TERMS 7 2013-01-24 "Notmuch 0.15.1"
2
3 .SH NAME
4 notmuch-search-terms \- syntax for notmuch queries
5
6 .SH SYNOPSIS
7
8 .B notmuch count
9 .RI  [ options... ]
10 .RI  < search-term ">..."
11
12 .B "notmuch dump"
13 .RI "[ <" filename "> ] [--]"
14 .RI "[ <" search-term ">...]"
15
16 .B notmuch search
17 .RI  [  options "...] <" search-term ">..."
18
19 .B notmuch show
20 .RI "[" options "...] <" search-term ">..."
21
22 .B notmuch tag
23 .RI  "+<" tag> "|\-<" tag "> [...] [\-\-] <" search-term ">..."
24
25
26 .SH DESCRIPTION
27 Several notmuch commands accept a common syntax for search terms.
28
29 The search terms can consist of free-form text (and quoted phrases)
30 which will match all messages that contain all of the given
31 terms/phrases in the body, the subject, or any of the sender or
32 recipient headers.
33
34 As a special case, a search string consisting of exactly a single
35 asterisk ("*") will match all messages.
36
37 In addition to free text, the following prefixes can be used to force
38 terms to match against specific portions of an email, (where
39 <brackets> indicate user-supplied values):
40
41         from:<name-or-address>
42
43         to:<name-or-address>
44
45         subject:<word-or-quoted-phrase>
46
47         attachment:<word>
48
49         tag:<tag> (or is:<tag>)
50
51         id:<message-id>
52
53         thread:<thread-id>
54
55         folder:<directory-path>
56
57         date:<since>..<until>
58
59 The
60 .B from:
61 prefix is used to match the name or address of the sender of an email
62 message.
63
64 The
65 .B to:
66 prefix is used to match the names or addresses of any recipient of an
67 email message, (whether To, Cc, or Bcc).
68
69 Any term prefixed with
70 .B subject:
71 will match only text from the subject of an email. Searching for a
72 phrase in the subject is supported by including quotation marks around
73 the phrase, immediately following
74 .BR subject: .
75
76 The
77 .B attachment:
78 prefix can be used to search for specific filenames (or extensions) of
79 attachments to email messages.
80
81 For
82 .BR tag: " and " is:
83 valid tag values include
84 .BR inbox " and " unread
85 by default for new messages added by
86 .B notmuch new
87 as well as any other tag values added manually with
88 .BR "notmuch tag" .
89
90 For
91 .BR id: ,
92 message ID values are the literal contents of the Message\-ID: header
93 of email messages, but without the '<', '>' delimiters.
94
95 The
96 .B thread:
97 prefix can be used with the thread ID values that are generated
98 internally by notmuch (and do not appear in email messages). These
99 thread ID values can be seen in the first column of output from
100 .B "notmuch search"
101
102 The
103 .B folder:
104 prefix can be used to search for email message files that are
105 contained within particular directories within the mail store. Only
106 the directory components below the top-level mail database path are
107 available to be searched.
108
109 The
110 .B date:
111 prefix can be used to restrict the results to only messages within a
112 particular time range (based on the Date: header) with a range syntax
113 of:
114
115         date:<since>..<until>
116
117 See \fBDATE AND TIME SEARCH\fR below for details on the range
118 expression, and supported syntax for <since> and <until> date and time
119 expressions.
120
121 The time range can also be specified using timestamps with a syntax
122 of:
123
124         <initial-timestamp>..<final-timestamp>
125
126 Each timestamp is a number representing the number of seconds since
127 1970\-01\-01 00:00:00 UTC.
128
129 In addition to individual terms, multiple terms can be
130 combined with Boolean operators (
131 .BR and ", " or ", " not
132 , etc.). Each term in the query will be implicitly connected by a
133 logical AND if no explicit operator is provided, (except that terms
134 with a common prefix will be implicitly combined with OR until we get
135 Xapian defect #402 fixed).
136
137 Parentheses can also be used to control the combination of the Boolean
138 operators, but will have to be protected from interpretation by the
139 shell, (such as by putting quotation marks around any parenthesized
140 expression).
141
142 .SH DATE AND TIME SEARCH
143
144 notmuch understands a variety of standard and natural ways of
145 expressing dates and times, both in absolute terms ("2012-10-24") and
146 in relative terms ("yesterday"). Any number of relative terms can be
147 combined ("1 hour 25 minutes") and an absolute date/time can be
148 combined with relative terms to further adjust it. A non-exhaustive
149 description of the syntax supported for absolute and relative terms is
150 given below.
151
152 .RS 4
153 .TP 4
154 .B The range expression
155
156 date:<since>..<until>
157
158 The above expression restricts the results to only messages from
159 <since> to <until>, based on the Date: header.
160
161 <since> and <until> can describe imprecise times, such as "yesterday".
162 In this case, <since> is taken as the earliest time it could describe
163 (the beginning of yesterday) and <until> is taken as the latest time
164 it could describe (the end of yesterday). Similarly,
165 date:january..february matches from the beginning of January to the
166 end of February.
167
168 Currently, we do not support spaces in range expressions. You can
169 replace the spaces with '_', or (in most cases) '-', or (in some
170 cases) leave the spaces out altogether. Examples in this man page use
171 spaces for clarity.
172
173 Open-ended ranges are supported (since Xapian 1.2.1), i.e. it's
174 possible to specify date:..<until> or date:<since>.. to not limit the
175 start or end time, respectively. Pre-1.2.1 Xapian does not report an
176 error on open ended ranges, but it does not work as expected either.
177
178 Entering date:expr without ".." (for example date:yesterday) won't
179 work, as it's not interpreted as a range expression at all. You can
180 achieve the expected result by duplicating the expr both sides of ".."
181 (for example date:yesterday..yesterday).
182 .RE
183
184 .RS 4
185 .TP 4
186 .B Relative date and time
187 [N|number] (years|months|weeks|days|hours|hrs|minutes|mins|seconds|secs) [...]
188
189 All refer to past, can be repeated and will be accumulated.
190
191 Units can be abbreviated to any length, with the otherwise ambiguous
192 single m being m for minutes and M for months.
193
194 Number can also be written out one, two, ..., ten, dozen,
195 hundred. Additionally, the unit may be preceded by "last" or "this"
196 (e.g., "last week" or "this month").
197
198 When combined with absolute date and time, the relative date and time
199 specification will be relative from the specified absolute date and
200 time.
201
202 Examples: 5M2d, two weeks
203 .RE
204
205 .RS 4
206 .TP 4
207 .B Supported absolute time formats
208 H[H]:MM[:SS] [(am|a.m.|pm|p.m.)]
209
210 H[H] (am|a.m.|pm|p.m.)
211
212 HHMMSS
213
214 now
215
216 noon
217
218 midnight
219
220 Examples: 17:05, 5pm
221 .RE
222
223 .RS 4
224 .TP 4
225 .B Supported absolute date formats
226 YYYY-MM[-DD]
227
228 DD-MM[-[YY]YY]
229
230 MM-YYYY
231
232 M[M]/D[D][/[YY]YY]
233
234 M[M]/YYYY
235
236 D[D].M[M][.[YY]YY]
237
238 D[D][(st|nd|rd|th)] Mon[thname] [YYYY]
239
240 Mon[thname] D[D][(st|nd|rd|th)] [YYYY]
241
242 Wee[kday]
243
244 Month names can be abbreviated at three or more characters.
245
246 Weekday names can be abbreviated at three or more characters.
247
248 Examples: 2012-07-31, 31-07-2012, 7/31/2012, August 3
249 .RE
250
251 .RS 4
252 .TP 4
253 .B Time zones
254 (+|-)HH:MM
255
256 (+|-)HH[MM]
257
258 Some time zone codes, e.g. UTC, EET.
259 .RE
260
261 .SH SEE ALSO
262
263 \fBnotmuch\fR(1), \fBnotmuch-config\fR(1), \fBnotmuch-count\fR(1),
264 \fBnotmuch-dump\fR(1), \fBnotmuch-hooks\fR(5), \fBnotmuch-new\fR(1),
265 \fBnotmuch-reply\fR(1), \fBnotmuch-restore\fR(1),
266 \fBnotmuch-search\fR(1), \fBnotmuch-show\fR(1), \fBnotmuch-tag\fR(1)