]> rtime.felk.cvut.cz Git - notmuch.git/blob - doc/man1/notmuch-search.rst
cli: Add configurable address deduplication for --output=addresses
[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|addresses)``
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             Handling of duplicate addresses and/or names can be
89             controlled with the --unique option.
90
91             Note: Searching for **sender** should much be faster than
92             searching for **recipients** or **addresses**, because
93             sender addresses are cached directly in the database
94             whereas other addresses need to be fetched from the
95             message file by parsing it.
96
97         **recipients**
98             Like **sender** but for addresses from *To*, *Cc* and
99             *Bcc* headers.
100
101         **addresses**
102             Like **sender** and **recipients** together.
103
104     ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)
105         This option can be used to present results in either
106         chronological order (**oldest-first**) or reverse chronological
107         order (**newest-first**).
108
109         Note: The thread order will be distinct between these two
110         options (beyond being simply reversed). When sorting by
111         **oldest-first** the threads will be sorted by the oldest
112         message in each thread, but when sorting by **newest-first** the
113         threads will be sorted by the newest message in each thread.
114
115         By default, results will be displayed in reverse chronological
116         order, (that is, the newest results will be displayed first).
117
118     ``--offset=[-]N``
119         Skip displaying the first N results. With the leading '-', start
120         at the Nth result from the end.
121
122     ``--limit=N``
123         Limit the number of displayed results to N.
124
125     ``--exclude=(true|false|all|flag)``
126         A message is called "excluded" if it matches at least one tag in
127         search.tag\_exclude that does not appear explicitly in the
128         search terms. This option specifies whether to omit excluded
129         messages in the search process.
130
131         The default value, **true**, prevents excluded messages from
132         matching the search terms.
133
134         **all** additionally prevents excluded messages from appearing
135         in displayed results, in effect behaving as though the excluded
136         messages do not exist.
137
138         **false** allows excluded messages to match search terms and
139         appear in displayed results. Excluded messages are still marked
140         in the relevant outputs.
141
142         **flag** only has an effect when ``--output=summary``. The
143         output is almost identical to **false**, but the "match count"
144         is the number of matching non-excluded messages in the thread,
145         rather than the number of matching messages.
146
147     ``--duplicate=N``
148         Effective with ``--output=files``, output the Nth filename
149         associated with each message matching the query (N is 1-based).
150         If N is greater than the number of files associated with the
151         message, don't print anything.
152
153         Note that this option is orthogonal with the **folder:** search
154         prefix. The prefix matches messages based on filenames. This
155         option filters filenames of the matching messages.
156
157     ``--unique=``\ (**none**\ \|\ **addr**\ \|\ **addrfold**\ \|\ **name**)[,\ ...]
158
159         Can be used with ``--output=addresses``, ``--output=sender``
160         or ``--output=recipients`` to control the address
161         deduplication algorithm.
162
163         **none** means that no deduplication is performed. The same
164         address can appear multiple times in the output.
165
166         **addr** means that case-sensitive deduplication is performed
167         on the address part. For example, given the addresses "John
168         Doe <john@example.com>" and "Dr. John Doe <john@example.com>",
169         only one will be printed.
170
171         **addrfold** means that case-insensitive deduplication is
172         performed on the address part. For example, given the
173         addresses "John Doe <john@example.com>" and "John Doe
174         <JOHN@EXAMPLE.COM>", only one will be printed. This is the
175         default.
176
177         **name** means that case-sensitive deduplication is performed
178         on the name part. For example, given the addresses "John Doe
179         <john@example.com>" and "John Doe <john@doe.name>", only one
180         will be printed.
181
182         It is possible to combine the above flags (except **none**) by
183         separating them with comma. For example,
184         ``--unique=name,addr`` will print unique case-sensitive
185         combinations of name and address.
186
187 EXIT STATUS
188 ===========
189
190 This command supports the following special exit status codes
191
192 ``20``
193     The requested format version is too old.
194
195 ``21``
196     The requested format version is too new.
197
198 SEE ALSO
199 ========
200
201 **notmuch(1)**, **notmuch-config(1)**, **notmuch-count(1)**,
202 **notmuch-dump(1)**, **notmuch-hooks(5)**, **notmuch-insert(1)**,
203 **notmuch-new(1)**, **notmuch-reply(1)**, **notmuch-restore(1)**,
204 **notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**