]> git.cworth.org Git - notmuch-wiki/blob - manpages/notmuch-search-terms-7.mdwn
ee5c1b2205455da5eccd42d6f365e327393bba3e
[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        · tag:&lt;tag&gt; (or is:&lt;tag&gt;)
47
48        · id:&lt;message-id&gt;
49
50        · thread:&lt;thread-id&gt;
51
52        · folder:&lt;maildir-folder&gt;
53
54        · path:&lt;directory-path&gt; or path:&lt;directory-path&gt;/**
55
56        · date:&lt;since&gt;..&lt;until&gt;
57
58        The <b>from:</b> prefix is used to match the name or address of the sender  of
59        an email message.
60
61        The <b>to:</b> prefix is used to match the names or addresses of any recipient
62        of an email message, (whether To, Cc, or Bcc).
63
64        Any term prefixed with <b>subject:</b> will match only text from  the  subject
65        of  an  email.  Searching  for  a phrase in the subject is supported by
66        including quotation marks around the phrase, immediately following <b>sub-</b>
67        <b>ject:</b>.
68
69        The <b>attachment:</b> prefix can be used to search for specific filenames (or
70        extensions) of attachments to email messages.
71
72        For <b>tag:</b> and <b>is:</b> valid tag values include <b>inbox</b> and <b>unread</b>  by  default
73        for  new  messages added by <b>notmuch</b> <b>new</b> as well as any other tag values
74        added manually with <b>notmuch</b> <b>tag</b>.
75
76        For <b>id:</b>, message ID values are the literal contents of the  Message-ID:
77        header of email messages, but without the &apos;&lt;&apos;, &apos;&gt;&apos; delimiters.
78
79        The  <b>thread:</b> prefix can be used with the thread ID values that are gen‐
80        erated internally by notmuch (and do not  appear  in  email  messages).
81        These  thread  ID values can be seen in the first column of output from
82        <b>notmuch</b> <b>search</b>
83
84        The <b>path:</b> prefix searches for email messages  that  are  in  particular
85        directories within the mail store. The directory must be specified rel‐
86        ative to the top-level maildir (and  without  the  leading  slash).  By
87        default,  <b>path:</b>  matches  messages in the specified directory only. The
88        &quot;/**&quot; suffix can be used to match messages in the  specified  directory
89        and  all  its  subdirectories recursively.  <b>path:&quot;&quot;</b> matches messages in
90        the root of the mail store and, likewise, <b>path:**</b> matches all messages.
91
92        The <b>folder:</b> prefix searches for email messages by maildir or MH folder.
93        For  MH-style  folders,  this is equivalent to <b>path:</b>. For maildir, this
94        includes messages in the &quot;new&quot; and &quot;cur&quot; subdirectories. The exact syn‐
95        tax  for  maildir  folders  depends  on  your  mail  configuration. For
96        maildir++, <b>folder:&quot;&quot;</b> matches the inbox folder (which  is  the  root  in
97        maildir++),  other folder names always start with &quot;.&quot;, and nested fold‐
98        ers are separated by &quot;.&quot;s, such as <b>folder:.classes.topology</b>. For  &quot;file
99        system&quot; maildir, the inbox is typically <b>folder:INBOX</b> and nested folders
100        are separated by slashes, such as <b>folder:classes/topology</b>.
101
102        Both <b>path:</b> and <b>folder:</b> will find a message if <u>any</u> copy of that  message
103        is in the specific directory/folder.
104
105        The  <b>date:</b>  prefix can be used to restrict the results to only messages
106        within a particular time range (based on the Date: header) with a range
107        syntax of:
108
109        date:&lt;since&gt;..&lt;until&gt;
110
111        See <b>DATE</b> <b>AND</b> <b>TIME</b> <b>SEARCH</b> below for details on the range expression, and
112        supported syntax for &lt;since&gt; and &lt;until&gt; date and time expressions.
113
114        The time range can also be specified using timestamps with a syntax of:
115
116        &lt;initial-timestamp&gt;..&lt;final-timestamp&gt;
117
118        Each timestamp is a number representing the  number  of  seconds  since
119        1970-01-01 00:00:00 UTC.
120
121        In  addition  to  individual terms, multiple terms can be combined with
122        Boolean operators ( <b>and</b>, <b>or</b>, <b>not</b> , etc.). Each term in the  query  will
123        be  implicitly  connected  by  a logical AND if no explicit operator is
124        provided, (except that terms with a common prefix  will  be  implicitly
125        combined with OR until we get Xapian defect #402 fixed).
126
127        Parentheses  can also be used to control the combination of the Boolean
128        operators, but will have to be protected  from  interpretation  by  the
129        shell,  (such  as  by  putting quotation marks around any parenthesized
130        expression).
131 </pre>
132
133 <h2>DATE AND TIME SEARCH</h2>
134 <pre>
135        notmuch understands a variety of standard and natural ways of  express‐
136        ing dates and times, both in absolute terms (&quot;2012-10-24&quot;) and in rela‐
137        tive terms (&quot;yesterday&quot;). Any number of relative terms can be  combined
138        (&quot;1  hour  25  minutes&quot;) and an absolute date/time can be combined with
139        relative terms to further adjust it. A  non-exhaustive  description  of
140        the syntax supported for absolute and relative terms is given below.
141 </pre>
142
143 <h3> &nbsp; The range expression</h3>
144 <pre>
145        date:&lt;since&gt;..&lt;until&gt;
146
147        The  above  expression  restricts  the  results  to  only messages from
148        &lt;since&gt; to &lt;until&gt;, based on the Date: header.
149
150        &lt;since&gt; and &lt;until&gt; can describe imprecise times, such as  &quot;yesterday&quot;.
151        In  this  case, &lt;since&gt; is taken as the earliest time it could describe
152        (the beginning of yesterday) and &lt;until&gt; is taken as the latest time it
153        could  describe (the end of yesterday). Similarly, date:january..febru‐
154        ary matches from the beginning of January to the end of February.
155
156        Currently, we do not support  spaces  in  range  expressions.  You  can
157        replace the spaces with &apos;_&apos;, or (in most cases) &apos;-&apos;, or (in some cases)
158        leave the spaces out altogether. Examples in this man page  use  spaces
159        for clarity.
160
161        Open-ended  ranges are supported (since Xapian 1.2.1), i.e. it&apos;s possi‐
162        ble to specify date:..&lt;until&gt; or date:&lt;since&gt;.. to not limit the  start
163        or end time, respectively. Pre-1.2.1 Xapian does not report an error on
164        open ended ranges, but it does not work as expected either.
165
166        Entering date:expr without  &quot;..&quot;  (for  example  date:yesterday)  won&apos;t
167        work,  as  it&apos;s  not  interpreted as a range expression at all. You can
168        achieve the expected result by duplicating the expr both sides of  &quot;..&quot;
169        (for example date:yesterday..yesterday).
170 </pre>
171
172 <h3> &nbsp; Relative date and time</h3>
173 <pre>
174        [N|number]         (years|months|weeks|days|hours|hrs|minutes|mins|sec‐
175        onds|secs) [...]
176
177        All refer to past, can be repeated and will be accumulated.
178
179        Units can be abbreviated to any length, with  the  otherwise  ambiguous
180        single m being m for minutes and M for months.
181
182        Number  can  also  be  written  out one, two, ..., ten, dozen, hundred.
183        Additionally, the unit may be preceded by &quot;last&quot; or &quot;this&quot; (e.g., &quot;last
184        week&quot; or &quot;this month&quot;).
185
186        When  combined  with absolute date and time, the relative date and time
187        specification will be relative from the  specified  absolute  date  and
188        time.
189
190        Examples: 5M2d, two weeks
191 </pre>
192
193 <h3> &nbsp; Supported absolute time formats</h3>
194 <pre>
195        · H[H]:MM[:SS] [(am|a.m.|pm|p.m.)]
196
197        · H[H] (am|a.m.|pm|p.m.)
198
199        · HHMMSS
200
201        · now
202
203        · noon
204
205        · midnight
206
207        · Examples: 17:05, 5pm
208 </pre>
209
210 <h3> &nbsp; Supported absolute date formats</h3>
211 <pre>
212        · YYYY-MM[-DD]
213
214        · DD-MM[-[YY]YY]
215
216        · MM-YYYY
217
218        · M[M]/D[D][/[YY]YY]
219
220        · M[M]/YYYY
221
222        · D[D].M[M][.[YY]YY]
223
224        · D[D][(st|nd|rd|th)] Mon[thname] [YYYY]
225
226        · Mon[thname] D[D][(st|nd|rd|th)] [YYYY]
227
228        · Wee[kday]
229
230        Month names can be abbreviated at three or more characters.
231
232        Weekday names can be abbreviated at three or more characters.
233
234        Examples: 2012-07-31, 31-07-2012, 7/31/2012, August 3
235 </pre>
236
237 <h3> &nbsp; Time zones</h3>
238 <pre>
239        · (+|-)HH:MM
240
241        · (+|-)HH[MM]
242
243        Some time zone codes, e.g. UTC, EET.
244 </pre>
245
246 <h2>SEE ALSO</h2>
247 <pre>
248        <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>
249        <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),
250        <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)
251 </pre>
252
253 <h2>AUTHOR</h2>
254 <pre>
255        Carl Worth and many others
256 </pre>
257
258 <h2>COPYRIGHT</h2>
259 <pre>
260        2014, Carl Worth and many others
261 </pre>
262
263 <h2>0.19</h2>