]> rtime.felk.cvut.cz Git - notmuch.git/blob - doc/man1/notmuch-search.rst
cli: search: Add --output=count
[notmuch.git] / doc / man1 / notmuch-search.rst
1 ==============
2 notmuch-search
3 ==============
4
5 SYNOPSIS
6 ========
7
8 **notmuch** **search** [*option* ...] <*search-term*> ...
9
10 DESCRIPTION
11 ===========
12
13 Search for messages matching the given search terms, and display as
14 results the threads containing the matched messages.
15
16 The output consists of one line per thread, giving a thread ID, the date
17 of the newest (or oldest, depending on the sort option) matched message
18 in the thread, the number of matched messages and total messages in the
19 thread, the names of all participants in the thread, and the subject of
20 the newest (or oldest) message.
21
22 See **notmuch-search-terms(7)** for details of the supported syntax for
23 <search-terms>.
24
25 Supported options for **search** include
26
27     ``--format=``\ (**json**\ \|\ **sexp**\ \|\ **text**\ \|\ **text0**)
28         Presents the results in either JSON, S-Expressions, newline
29         character separated plain-text (default), or null character
30         separated plain-text (compatible with **xargs(1)** -0 option
31         where available).
32
33     ``--format-version=N``
34         Use the specified structured output format version. This is
35         intended for programs that invoke **notmuch(1)** internally. If
36         omitted, the latest supported version will be used.
37
38     ``--output=(summary|threads|messages|files|tags|sender|recipients)``
39
40         **summary**
41             Output a summary of each thread with any message matching
42             the search terms. The summary includes the thread ID, date,
43             the number of messages in the thread (both the number
44             matched and the total number), the authors of the thread and
45             the subject.
46
47         **threads**
48             Output the thread IDs of all threads with any message
49             matching the search terms, either one per line
50             (--format=text), separated by null characters
51             (--format=text0), as a JSON array (--format=json), or an
52             S-Expression list (--format=sexp).
53
54         **messages**
55             Output the message IDs of all messages matching the search
56             terms, either one per line (--format=text), separated by
57             null characters (--format=text0), as a JSON array
58             (--format=json), or as an S-Expression list (--format=sexp).
59
60         **files**
61             Output the filenames of all messages matching the search
62             terms, either one per line (--format=text), separated by
63             null characters (--format=text0), as a JSON array
64             (--format=json), or as an S-Expression list (--format=sexp).
65
66             Note that each message may have multiple filenames
67             associated with it. All of them are included in the output
68             (unless limited with the --duplicate=N option). This may
69             be particularly confusing for **folder:** or **path:**
70             searches in a specified directory, as the messages may
71             have duplicates in other directories that are included in
72             the output, although these files alone would not match the
73             search.
74
75         **tags**
76             Output all tags that appear on any message matching the
77             search terms, either one per line (--format=text), separated
78             by null characters (--format=text0), as a JSON array
79             (--format=json), or as an S-Expression list (--format=sexp).
80
81         **sender**
82             Output all addresses from the *From* header that appear on
83             any message matching the search terms, either one per line
84             (--format=text), separated by null characters
85             (--format=text0), as a JSON array (--format=json), or as
86             an S-Expression list (--format=sexp).
87
88             Duplicate addresses are filtered out. Filtering can be
89             configured with the --filter-by option.
90
91             Note: Searching for **sender** should be much faster than
92             searching for **recipients**, because sender addresses are
93             cached directly in the database whereas other addresses
94             need to be fetched from message files.
95
96         **recipients**
97             Like **sender** but for addresses from *To*, *Cc* and
98             *Bcc* headers.
99
100         **count**
101             Can be used in combination with **sender** or
102             **recipients** to print the count of how many times was
103             the address encountered during search.
104
105         This option can be given multiple times to combine different
106         outputs. Currently, this is only supported for **sender**,
107         **recipients** and **count** outputs.
108
109     ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)
110         This option can be used to present results in either
111         chronological order (**oldest-first**) or reverse chronological
112         order (**newest-first**).
113
114         Note: The thread order will be distinct between these two
115         options (beyond being simply reversed). When sorting by
116         **oldest-first** the threads will be sorted by the oldest
117         message in each thread, but when sorting by **newest-first** the
118         threads will be sorted by the newest message in each thread.
119
120         By default, results will be displayed in reverse chronological
121         order, (that is, the newest results will be displayed first).
122
123     ``--offset=[-]N``
124         Skip displaying the first N results. With the leading '-', start
125         at the Nth result from the end.
126
127     ``--limit=N``
128         Limit the number of displayed results to N.
129
130     ``--exclude=(true|false|all|flag)``
131         A message is called "excluded" if it matches at least one tag in
132         search.tag\_exclude that does not appear explicitly in the
133         search terms. This option specifies whether to omit excluded
134         messages in the search process.
135
136         The default value, **true**, prevents excluded messages from
137         matching the search terms.
138
139         **all** additionally prevents excluded messages from appearing
140         in displayed results, in effect behaving as though the excluded
141         messages do not exist.
142
143         **false** allows excluded messages to match search terms and
144         appear in displayed results. Excluded messages are still marked
145         in the relevant outputs.
146
147         **flag** only has an effect when ``--output=summary``. The
148         output is almost identical to **false**, but the "match count"
149         is the number of matching non-excluded messages in the thread,
150         rather than the number of matching messages.
151
152     ``--duplicate=N``
153         Effective with ``--output=files``, output the Nth filename
154         associated with each message matching the query (N is 1-based).
155         If N is greater than the number of files associated with the
156         message, don't print anything.
157
158         Note that this option is orthogonal with the **folder:** search
159         prefix. The prefix matches messages based on filenames. This
160         option filters filenames of the matching messages.
161
162     ``--filter-by=``\ (**nameaddr**\ \|\ **name** \|\ **addr**\ \|\ **addrfold**\ \|\ **nameaddrfold**\)
163
164         Can be used with ``--output=sender`` or
165         ``--output=recipients`` to filter out duplicate addresses. The
166         filtering algorithm receives a sequence of email addresses and
167         outputs the same sequence without the addresses that are
168         considered a duplicate of a previously output address. What is
169         considered a duplicate depends on how the two addresses are
170         compared and this can be controlled with the follwing flags:
171
172         **nameaddr** means that both name and address parts are
173         compared in case-sensitive manner. Therefore, all same looking
174         addresses strings are considered duplicate. This is the
175         default.
176
177         **name** means that only the name part is compared (in
178         case-sensitive manner). For example, the addresses "John Doe
179         <me@example.com>" and "John Doe <john@doe.name>" will be
180         considered duplicate.
181
182         **addr** means that only the address part is compared (in
183         case-sensitive manner). For example, the addresses "John Doe
184         <john@example.com>" and "Dr. John Doe <john@example.com>" will
185         be considered duplicate.
186
187         **addrfold** is like **addr**, but comparison is done in
188         canse-insensitive manner. For example, the addresses "John Doe
189         <john@example.com>" and "Dr. John Doe <JOHN@EXAMPLE.COM>" will
190         be considered duplicate.
191
192         **nameaddrfold** is like **nameaddr**, but address comparison
193         is done in canse-insensitive manner. For example, the
194         addresses "John Doe <john@example.com>" and "John Doe
195         <JOHN@EXAMPLE.COM>" will be considered duplicate.
196
197 EXIT STATUS
198 ===========
199
200 This command supports the following special exit status codes
201
202 ``20``
203     The requested format version is too old.
204
205 ``21``
206     The requested format version is too new.
207
208 SEE ALSO
209 ========
210
211 **notmuch(1)**, **notmuch-config(1)**, **notmuch-count(1)**,
212 **notmuch-dump(1)**, **notmuch-hooks(5)**, **notmuch-insert(1)**,
213 **notmuch-new(1)**, **notmuch-reply(1)**, **notmuch-restore(1)**,
214 **notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**