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