]> git.cworth.org Git - notmuch-wiki/blob - manpages/notmuch-search-terms-7.mdwn
0.20.1 manpages update
[notmuch-wiki] / manpages / notmuch-search-terms-7.mdwn
1 <h1>NOTMUCH-SEARCH-TERMS(7)</h1>
2
3 <h2>NAME</h2>
4 <pre>
5        notmuch-search-terms - syntax for notmuch queries
6 </pre>
7
8 <h2>SYNOPSIS</h2>
9 <pre>
10        <b>notmuch</b> <b>count</b> [option ...] &lt;<u>search-term</u>&gt; ...
11
12        <b>notmuch</b>  <b>dump</b>  [--format=(batch-tag|sup)]  [--]  [--output=&lt;<u>file</u>&gt;] [--]
13        [&lt;<u>search-term</u>&gt; ...]
14
15        <b>notmuch</b> <b>search</b> [option ...] &lt;<u>search-term</u>&gt; ...
16
17        <b>notmuch</b> <b>show</b> [option ...] &lt;<u>search-term</u>&gt; ...
18
19        <b>notmuch</b> <b>tag</b> +&lt;<u>tag</u>&gt; ... -&lt;<u>tag</u>&gt; [--] &lt;<u>search-term</u>&gt; ...
20 </pre>
21
22 <h2>DESCRIPTION</h2>
23 <pre>
24        Several notmuch commands accept a common syntax for search terms.
25
26        The search terms can consist of free-form  text  (and  quoted  phrases)
27        which   will   match  all  messages  that  contain  all  of  the  given
28        terms/phrases in the body, the subject, or any of the sender or recipi‐
29        ent headers.
30
31        As  a  special  case,  a  search  string consisting of exactly a single
32        asterisk (&quot;*&quot;) will match all messages.
33
34        In addition to free text, the following prefixes can be used  to  force
35        terms to match against specific portions of an email, (where &lt;brackets&gt;
36        indicate user-supplied values):
37
38        · from:&lt;name-or-address&gt;
39
40        · to:&lt;name-or-address&gt;
41
42        · subject:&lt;word-or-quoted-phrase&gt;
43
44        · attachment:&lt;word&gt;
45
46        · mimetype:&lt;word&gt;
47
48        · tag:&lt;tag&gt; (or is:&lt;tag&gt;)
49
50        · id:&lt;message-id&gt;
51
52        · thread:&lt;thread-id&gt;
53
54        · folder:&lt;maildir-folder&gt;
55
56        · path:&lt;directory-path&gt; or path:&lt;directory-path&gt;/**
57
58        · date:&lt;since&gt;..&lt;until&gt;
59
60        The <b>from:</b> prefix is used to match the name or address of the sender  of
61        an email message.
62
63        The <b>to:</b> prefix is used to match the names or addresses of any recipient
64        of an email message, (whether To, Cc, or Bcc).
65
66        Any term prefixed with <b>subject:</b> will match only text from  the  subject
67        of  an  email.  Searching  for  a phrase in the subject is supported by
68        including quotation marks around the phrase, immediately following <b>sub-</b>
69        <b>ject:</b>.
70
71        The <b>attachment:</b> prefix can be used to search for specific filenames (or
72        extensions) of attachments to email messages.
73
74        The <b>mimetype:</b> prefix will be used to match text from the  content-types
75        of MIME parts within email messages (as specified by the sender).
76
77        For  <b>tag:</b>  and <b>is:</b> valid tag values include <b>inbox</b> and <b>unread</b> by default
78        for new messages added by <b>notmuch</b> <b>new</b> as well as any other  tag  values
79        added manually with <b>notmuch</b> <b>tag</b>.
80
81        For  <b>id:</b>, message ID values are the literal contents of the Message-ID:
82        header of email messages, but without the &apos;&lt;&apos;, &apos;&gt;&apos; delimiters.
83
84        The <b>thread:</b> prefix can be used with the thread ID values that are  gen‐
85        erated  internally  by  notmuch  (and do not appear in email messages).
86        These thread ID values can be seen in the first column of  output  from
87        <b>notmuch</b> <b>search</b>
88
89        The  <b>path:</b>  prefix  searches  for email messages that are in particular
90        directories within the mail store. The directory must be specified rel‐
91        ative  to  the  top-level  maildir  (and without the leading slash). By
92        default, <b>path:</b> matches messages in the specified  directory  only.  The
93        &quot;/**&quot;  suffix  can be used to match messages in the specified directory
94        and all its subdirectories recursively.  <b>path:&quot;&quot;</b>  matches  messages  in
95        the root of the mail store and, likewise, <b>path:**</b> matches all messages.
96
97        The <b>folder:</b> prefix searches for email messages by maildir or MH folder.
98        For MH-style folders, this is equivalent to <b>path:</b>.  For  maildir,  this
99        includes messages in the &quot;new&quot; and &quot;cur&quot; subdirectories. The exact syn‐
100        tax for  maildir  folders  depends  on  your  mail  configuration.  For
101        maildir++,  <b>folder:&quot;&quot;</b>  matches  the  inbox folder (which is the root in
102        maildir++), other folder names always start with &quot;.&quot;, and nested  fold‐
103        ers  are separated by &quot;.&quot;s, such as <b>folder:.classes.topology</b>. For &quot;file
104        system&quot; maildir, the inbox is typically <b>folder:INBOX</b> and nested folders
105        are separated by slashes, such as <b>folder:classes/topology</b>.
106
107        Both  <b>path:</b> and <b>folder:</b> will find a message if <u>any</u> copy of that message
108        is in the specific directory/folder.
109
110        The <b>date:</b> prefix can be used to restrict the results to  only  messages
111        within a particular time range (based on the Date: header) with a range
112        syntax of:
113
114        date:&lt;since&gt;..&lt;until&gt;
115
116        See <b>DATE</b> <b>AND</b> <b>TIME</b> <b>SEARCH</b> below for details on the range expression, and
117        supported syntax for &lt;since&gt; and &lt;until&gt; date and time expressions.
118
119        The time range can also be specified using timestamps with a syntax of:
120
121        &lt;initial-timestamp&gt;..&lt;final-timestamp&gt;
122
123        Each  timestamp  is  a  number representing the number of seconds since
124        1970-01-01 00:00:00 UTC.
125 </pre>
126
127 <h3> &nbsp; Operators</h3>
128 <pre>
129        In addition to individual terms, multiple terms can  be  combined  with
130        Boolean  operators (<b>and</b>, <b>or</b>, <b>not</b>, and <b>xor</b>). Each term in the query will
131        be implicitly connected by a logical AND if  no  explicit  operator  is
132        provided  (except  that  terms  with a common prefix will be implicitly
133        combined with OR).  The  shorthand  &apos;-&lt;term&gt;&apos;  can  be  used  for  &apos;not
134        &lt;term&gt;&apos; but unfortunately this does not work at the start of an expres‐
135        sion.  Parentheses can also be used to control the combination  of  the
136        Boolean operators, but will have to be protected from interpretation by
137        the shell, (such as by putting quotation marks around any parenthesized
138        expression).
139
140        In  addition to the standard boolean operators, Xapian provides several
141        operators specific to text searching.
142
143           notmuch search term1 NEAR term2
144
145        will return results where term1  is  within  10  words  of  term2.  The
146        threshold can be set like this:
147
148           notmuch search term1 NEAR/2 term2
149
150        The search
151
152           notmuch search term1 ADJ term2
153
154        will return results where term1 is within 10 words of term2, but in the
155        same order as in the query. The threshold can be set the same  as  with
156        NEAR:
157
158           notmuch search term1 ADJ/7 term2
159 </pre>
160
161 <h3> &nbsp; Stemming</h3>
162 <pre>
163        <b>Stemming</b> in notmuch means that these searches
164
165           notmuch search detailed
166           notmuch search details
167           notmuch search detail
168
169        will  all  return identical results, because Xapian first &quot;reduces&quot; the
170        term to the common stem (here &apos;detail&apos;) and then performs the search.
171
172        There are two ways to turn this off: a search for  a  capitalized  word
173        will  be performed unstemmed, so that one can search for &quot;John&quot; and not
174        get results for &quot;Johnson&quot;; phrase  searches  are  also  unstemmed  (see
175        below  for details).  Stemming is currently only supported for English.
176        Searches for words in other languages will be performed unstemmed.
177 </pre>
178
179 <h3> &nbsp; Wildcards</h3>
180 <pre>
181        It is possible to use a trailing  &apos;*&apos;  as  a  wildcard.  A  search  for
182        &apos;wildc*&apos; will match &apos;wildcard&apos;, &apos;wildcat&apos;, etc.
183 </pre>
184
185 <h3> &nbsp; Boolean and Probabilistic Prefixes</h3>
186 <pre>
187        Xapian  (and  hence  notmuch)  prefixes  are either <b>boolean</b>, supporting
188        exact matches like &quot;<u>tag:inbox</u>&quot;  or  <b>probabilistic</b>,  supporting  a  more
189        flexible <b>term</b> based searching. The prefixes currently supported by not‐
190        much are as follows.
191
192               ┌───────────────────────────┬────────────────────────────┐
193               │Boolean
194               ├───────────────────────────┼────────────────────────────┤
195               │
196               │
197               │       <b>thread:</b>     <b>folder:</b> │        <b>subject:</b>    <b>attach‐</b> │
198               │       <b>path:</b>               │        <b>ment:</b> <b>mimetype:</b>     │
199               └───────────────────────────┴────────────────────────────┘
200 </pre>
201
202 <h3> &nbsp; Terms and phrases</h3>
203 <pre>
204        In general Xapian distinguishes between lists  of  terms  and  <b>phrases</b>.
205        Phrases are indicated by double quotes (but beware you probably need to
206        protect those from your shell) and insist that  those  unstemmed  words
207        occur  in  that  order. One useful, but initially surprising feature is
208        that the following are equivalant ways to write the same phrase.
209
210        · &quot;a list of words&quot;
211
212        · a-list-of-words
213
214        · a/list/of/words
215
216        · a.list.of.words
217
218        Both parenthesised lists of terms and quoted phrases are ok with proba‐
219        bilisitic prefixes such as <b>to:</b>, <b>from:</b>, and <b>subject:</b>. In particular
220
221           subject:(pizza free)
222
223        is equivalent to
224
225           subject:pizza and subject:free
226
227        Both of these will match a subject &quot;Free Delicious Pizza&quot; while
228
229           subject:&quot;pizza free&quot;
230
231        will not.
232 </pre>
233
234 <h2>DATE AND TIME SEARCH</h2>
235 <pre>
236        notmuch  understands a variety of standard and natural ways of express‐
237        ing dates and times, both in absolute terms (&quot;2012-10-24&quot;) and in rela‐
238        tive  terms (&quot;yesterday&quot;). Any number of relative terms can be combined
239        (&quot;1 hour 25 minutes&quot;) and an absolute date/time can  be  combined  with
240        relative  terms  to  further adjust it. A non-exhaustive description of
241        the syntax supported for absolute and relative terms is given below.
242 </pre>
243
244 <h3> &nbsp; The range expression</h3>
245 <pre>
246        date:&lt;since&gt;..&lt;until&gt;
247
248        The above expression  restricts  the  results  to  only  messages  from
249        &lt;since&gt; to &lt;until&gt;, based on the Date: header.
250
251        &lt;since&gt;  and &lt;until&gt; can describe imprecise times, such as &quot;yesterday&quot;.
252        In this case, &lt;since&gt; is taken as the earliest time it  could  describe
253        (the beginning of yesterday) and &lt;until&gt; is taken as the latest time it
254        could describe (the end of yesterday). Similarly,  date:january..febru‐
255        ary matches from the beginning of January to the end of February.
256
257        Currently,  we  do  not  support  spaces  in range expressions. You can
258        replace the spaces with &apos;_&apos;, or (in most cases) &apos;-&apos;, or (in some cases)
259        leave  the  spaces out altogether. Examples in this man page use spaces
260        for clarity.
261
262        Open-ended ranges are supported (since Xapian 1.2.1), i.e. it&apos;s  possi‐
263        ble  to specify date:..&lt;until&gt; or date:&lt;since&gt;.. to not limit the start
264        or end time, respectively. Pre-1.2.1 Xapian does not report an error on
265        open ended ranges, but it does not work as expected either.
266
267        Entering  date:expr  without  &quot;..&quot;  (for  example date:yesterday) won&apos;t
268        work, as it&apos;s not interpreted as a range expression  at  all.  You  can
269        achieve  the expected result by duplicating the expr both sides of &quot;..&quot;
270        (for example date:yesterday..yesterday).
271 </pre>
272
273 <h3> &nbsp; Relative date and time</h3>
274 <pre>
275        [N|number]         (years|months|weeks|days|hours|hrs|minutes|mins|sec‐
276        onds|secs) [...]
277
278        All refer to past, can be repeated and will be accumulated.
279
280        Units  can  be  abbreviated to any length, with the otherwise ambiguous
281        single m being m for minutes and M for months.
282
283        Number can also be written out one,  two,  ...,  ten,  dozen,  hundred.
284        Additionally, the unit may be preceded by &quot;last&quot; or &quot;this&quot; (e.g., &quot;last
285        week&quot; or &quot;this month&quot;).
286
287        When combined with absolute date and time, the relative date  and  time
288        specification  will  be  relative  from the specified absolute date and
289        time.
290
291        Examples: 5M2d, two weeks
292 </pre>
293
294 <h3> &nbsp; Supported absolute time formats</h3>
295 <pre>
296        · H[H]:MM[:SS] [(am|a.m.|pm|p.m.)]
297
298        · H[H] (am|a.m.|pm|p.m.)
299
300        · HHMMSS
301
302        · now
303
304        · noon
305
306        · midnight
307
308        · Examples: 17:05, 5pm
309 </pre>
310
311 <h3> &nbsp; Supported absolute date formats</h3>
312 <pre>
313        · YYYY-MM[-DD]
314
315        · DD-MM[-[YY]YY]
316
317        · MM-YYYY
318
319        · M[M]/D[D][/[YY]YY]
320
321        · M[M]/YYYY
322
323        · D[D].M[M][.[YY]YY]
324
325        · D[D][(st|nd|rd|th)] Mon[thname] [YYYY]
326
327        · Mon[thname] D[D][(st|nd|rd|th)] [YYYY]
328
329        · Wee[kday]
330
331        Month names can be abbreviated at three or more characters.
332
333        Weekday names can be abbreviated at three or more characters.
334
335        Examples: 2012-07-31, 31-07-2012, 7/31/2012, August 3
336 </pre>
337
338 <h3> &nbsp; Time zones</h3>
339 <pre>
340        · (+|-)HH:MM
341
342        · (+|-)HH[MM]
343
344        Some time zone codes, e.g. UTC, EET.
345 </pre>
346
347 <h2>SEE ALSO</h2>
348 <pre>
349        <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>
350        <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),
351        <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)
352 </pre>
353
354 <h2>AUTHOR</h2>
355 <pre>
356        Carl Worth and many others
357 </pre>
358
359 <h2>COPYRIGHT</h2>
360 <pre>
361        2014, Carl Worth and many others
362 </pre>
363
364 <h2>0.20.1</h2>