1 <h1>NOTMUCH-SEARCH(1)</h1>
5 notmuch-search - search for messages matching the given search terms
10 <b>notmuch</b> <b>search</b> [<u>option</u> ...] <<u>search-term</u>> ...
15 Search for messages matching the given search terms, and display as
16 results the threads containing the matched messages.
18 The output consists of one line per thread, giving a thread ID, the
19 date of the newest (or oldest, depending on the sort option) matched
20 message in the thread, the number of matched messages and total mes‐
21 sages in the thread, the names of all participants in the thread, and
22 the subject of the newest (or oldest) message.
24 See <a href='../notmuch-search-terms-7/'>notmuch-search-terms</a>(7) for details of the supported syntax for
27 Supported options for <b>search</b> include
29 <b>--format=(json|sexp|text|text0)</b>
30 Presents the results in either JSON, S-Expressions, newline
31 character separated plain-text (default), or null character
32 separated plain-text (compatible with <b>xargs</b>(1) -0 option
35 <b>--format-version=N</b>
36 Use the specified structured output format version. This is
37 intended for programs that invoke <a href='../notmuch-1/'>notmuch</a>(1) internally. If
38 omitted, the latest supported version will be used.
40 <b>--output=(summary|threads|messages|files|tags)</b>
43 Output a summary of each thread with any message matching
44 the search terms. The summary includes the thread ID,
45 date, the number of messages in the thread (both the num‐
46 ber matched and the total number), the authors of the
47 thread and the subject.
50 Output the thread IDs of all threads with any message
51 matching the search terms, either one per line (--for‐
52 mat=text), separated by null characters (--format=text0),
53 as a JSON array (--format=json), or an S-Expression list
57 Output the message IDs of all messages matching the
58 search terms, either one per line (--format=text), sepa‐
59 rated by null characters (--format=text0), as a JSON
60 array (--format=json), or as an S-Expression list (--for‐
63 <b>files</b> 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 (--for‐
66 mat=json), or as an S-Expression list (--format=sexp).
68 Note that each message may have multiple filenames asso‐
69 ciated 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 <b>folder:</b> or <b>path:</b> searches
72 in a specified directory, as the messages may have dupli‐
73 cates in other directories that are included in the out‐
74 put, although these files alone would not match the
77 <b>tags</b> Output all tags that appear on any message matching the
78 search terms, either one per line (--format=text), sepa‐
79 rated by null characters (--format=text0), as a JSON
80 array (--format=json), or as an S-Expression list (--for‐
83 <b>--sort=(newest-first|oldest-first)</b>
84 This option can be used to present results in either chrono‐
85 logical order (<b>oldest-first</b>) or reverse chronological order
86 (<b>newest-first</b>).
88 Note: The thread order will be distinct between these two
89 options (beyond being simply reversed). When sorting by <b>old-</b>
90 <b>est-first</b> the threads will be sorted by the oldest message in
91 each thread, but when sorting by <b>newest-first</b> the threads
92 will be sorted by the newest message in each thread.
94 By default, results will be displayed in reverse chronologi‐
95 cal order, (that is, the newest results will be displayed
99 Skip displaying the first N results. With the leading '-',
100 start at the Nth result from the end.
103 Limit the number of displayed results to N.
105 <b>--exclude=(true|false|all|flag)</b>
106 A message is called "excluded" if it matches at least one tag
107 in search.tag_exclude that does not appear explicitly in the
108 search terms. This option specifies whether to omit excluded
109 messages in the search process.
111 The default value, <b>true</b>, prevents excluded messages from
112 matching the search terms.
114 <b>all</b> additionally prevents excluded messages from appearing in
115 displayed results, in effect behaving as though the excluded
116 messages do not exist.
118 <b>false</b> allows excluded messages to match search terms and
119 appear in displayed results. Excluded messages are still
120 marked in the relevant outputs.
122 <b>flag</b> only has an effect when <b>--output=summary</b>. The output is
123 almost identical to <b>false</b>, but the "match count" is the num‐
124 ber of matching non-excluded messages in the thread, rather
125 than the number of matching messages.
128 For <b>--output=files</b>, output the Nth filename associated with
129 each message matching the query (N is 1-based). If N is
130 greater than the number of files associated with the message,
131 don't print anything.
133 For <b>--output=messages</b>, only output message IDs of messages
134 matching the search terms that have at least N filenames
135 associated with them.
137 Note that this option is orthogonal with the <b>folder:</b> search
138 prefix. The prefix matches messages based on filenames. This
139 option filters filenames of the matching messages.
144 This command supports the following special exit status codes
146 <b>20</b> The requested format version is too old.
148 <b>21</b> The requested format version is too new.
153 <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>
154 <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),
155 <a href='../notmuch-restore-1/'>notmuch-restore</a>(1), <a href='../notmuch-search-terms-7/'>notmuch-search-terms</a>(7), <a href='../notmuch-show-1/'>notmuch-show</a>(1), <a href='../notmuch-tag-1/'>not‐</a>
156 <a href='../notmuch-tag-1/'>much-tag</a>(1) <a href='../notmuch-address-1/'>notmuch-address</a>(1)
161 Carl Worth and many others
166 2009-2017, Carl Worth and many others