]> git.notmuchmail.org Git - notmuch/blob - doc/man1/notmuch-search.rst
cli/insert: add --try-decrypt=(true|false)
[notmuch] / 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)``
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. In the case where a thread contains multiple files for
46             some messages, the total number of files is printed in parentheses
47             (see below for an example).
48
49         **threads**
50             Output the thread IDs of all threads with any message
51             matching the search terms, either one per line
52             (--format=text), separated by null characters
53             (--format=text0), as a JSON array (--format=json), or an
54             S-Expression list (--format=sexp).
55
56         **messages**
57             Output the message IDs of all messages matching the search
58             terms, either one per line (--format=text), separated by
59             null characters (--format=text0), as a JSON array
60             (--format=json), or as an S-Expression list (--format=sexp).
61
62         **files**
63             Output the filenames of all messages matching the search
64             terms, either one per line (--format=text), separated by
65             null characters (--format=text0), as a JSON array
66             (--format=json), or as an S-Expression list (--format=sexp).
67
68             Note that each message may have multiple filenames
69             associated with it. All of them are included in the output
70             (unless limited with the --duplicate=N option). This may
71             be particularly confusing for **folder:** or **path:**
72             searches in a specified directory, as the messages may
73             have duplicates in other directories that are included in
74             the output, although these files alone would not match the
75             search.
76
77         **tags**
78             Output all tags that appear on any message matching the
79             search terms, either one per line (--format=text), separated
80             by null characters (--format=text0), as a JSON array
81             (--format=json), or as an S-Expression list (--format=sexp).
82
83     ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)
84         This option can be used to present results in either
85         chronological order (**oldest-first**) or reverse chronological
86         order (**newest-first**).
87
88         Note: The thread order will be distinct between these two
89         options (beyond being simply reversed). When sorting by
90         **oldest-first** the threads will be sorted by the oldest
91         message in each thread, but when sorting by **newest-first** the
92         threads will be sorted by the newest message in each thread.
93
94         By default, results will be displayed in reverse chronological
95         order, (that is, the newest results will be displayed first).
96
97     ``--offset=[-]N``
98         Skip displaying the first N results. With the leading '-', start
99         at the Nth result from the end.
100
101     ``--limit=N``
102         Limit the number of displayed results to N.
103
104     ``--exclude=(true|false|all|flag)``
105         A message is called "excluded" if it matches at least one tag in
106         search.tag\_exclude that does not appear explicitly in the
107         search terms. This option specifies whether to omit excluded
108         messages in the search process.
109
110         The default value, **true**, prevents excluded messages from
111         matching the search terms.
112
113         **all** additionally prevents excluded messages from appearing
114         in displayed results, in effect behaving as though the excluded
115         messages do not exist.
116
117         **false** allows excluded messages to match search terms and
118         appear in displayed results. Excluded messages are still marked
119         in the relevant outputs.
120
121         **flag** only has an effect when ``--output=summary``. The
122         output is almost identical to **false**, but the "match count"
123         is the number of matching non-excluded messages in the thread,
124         rather than the number of matching messages.
125
126     ``--duplicate=N``
127         For ``--output=files``, output the Nth filename associated
128         with each message matching the query (N is 1-based). If N is
129         greater than the number of files associated with the message,
130         don't print anything.
131
132         For ``--output=messages``, only output message IDs of messages
133         matching the search terms that have at least N filenames
134         associated with them.
135
136         Note that this option is orthogonal with the **folder:** search
137         prefix. The prefix matches messages based on filenames. This
138         option filters filenames of the matching messages.
139
140 EXAMPLE
141 =======
142
143 The following shows an example of the summary output format, with one
144 message having multiple filenames.
145
146 ::
147
148   % notmuch search date:today.. and tag:bad-news
149   thread:0000000000063c10 Today [1/1] Some Persun; To the bone (inbox unread)
150   thread:0000000000063c25 Today [1/1(2)] Ann Other; Bears (inbox unread)
151   thread:0000000000063c00 Today [1/1] A Thurd; Bites, stings, sad feelings (inbox unread)
152
153 EXIT STATUS
154 ===========
155
156 This command supports the following special exit status codes
157
158 ``20``
159     The requested format version is too old.
160
161 ``21``
162     The requested format version is too new.
163
164 SEE ALSO
165 ========
166
167 **notmuch(1)**,
168 **notmuch-config(1)**,
169 **notmuch-count(1)**,
170 **notmuch-dump(1)**,
171 **notmuch-hooks(5)**,
172 **notmuch-insert(1)**,
173 **notmuch-new(1)**,
174 **notmuch-reply(1)**,
175 **notmuch-restore(1)**,
176 **notmuch-search-terms(7)**,
177 **notmuch-show(1)**,
178 **notmuch-tag(1)**
179 **notmuch-address(1)**