]> git.notmuchmail.org Git - notmuch/blob - doc/man1/notmuch-search.rst
doc: convert sphinx based docs
[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.
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.
69
70         **tags**
71             Output all tags that appear on any message matching the
72             search terms, either one per line (--format=text), separated
73             by null characters (--format=text0), as a JSON array
74             (--format=json), or as an S-Expression list (--format=sexp).
75
76     ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)
77         This option can be used to present results in either
78         chronological order (**oldest-first**) or reverse chronological
79         order (**newest-first**).
80
81         Note: The thread order will be distinct between these two
82         options (beyond being simply reversed). When sorting by
83         **oldest-first** the threads will be sorted by the oldest
84         message in each thread, but when sorting by **newest-first** the
85         threads will be sorted by the newest message in each thread.
86
87         By default, results will be displayed in reverse chronological
88         order, (that is, the newest results will be displayed first).
89
90     ``--offset=[-]N``
91         Skip displaying the first N results. With the leading '-', start
92         at the Nth result from the end.
93
94     ``--limit=N``
95         Limit the number of displayed results to N.
96
97     ``--exclude=(true|false|all|flag)``
98         A message is called "excluded" if it matches at least one tag in
99         search.tag\_exclude that does not appear explicitly in the
100         search terms. This option specifies whether to omit excluded
101         messages in the search process.
102
103         The default value, **true**, prevents excluded messages from
104         matching the search terms.
105
106         **all** additionally prevents excluded messages from appearing
107         in displayed results, in effect behaving as though the excluded
108         messages do not exist.
109
110         **false** allows excluded messages to match search terms and
111         appear in displayed results. Excluded messages are still marked
112         in the relevant outputs.
113
114         **flag** only has an effect when ``--output=summary``. The
115         output is almost identical to **false**, but the "match count"
116         is the number of matching non-excluded messages in the thread,
117         rather than the number of matching messages.
118
119     ``--duplicate=N``
120         Effective with ``--output=files``, output the Nth filename
121         associated with each message matching the query (N is 1-based).
122         If N is greater than the number of files associated with the
123         message, don't print anything.
124
125         Note that this option is orthogonal with the **folder:** search
126         prefix. The prefix matches messages based on filenames. This
127         option filters filenames of the matching messages.
128
129 EXIT STATUS
130 ===========
131
132 This command supports the following special exit status codes
133
134 ``20``
135     The requested format version is too old.
136
137 ``21``
138     The requested format version is too new.
139
140 SEE ALSO
141 ========
142
143 **notmuch(1)**, **notmuch-config(1)**, **notmuch-count(1)**,
144 **notmuch-dump(1)**, **notmuch-hooks(5)**, **notmuch-insert(1)**,
145 **notmuch-new(1)**, **notmuch-reply(1)**, **notmuch-restore(1)**,
146 **notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**