1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Searching with Notmuch
4 What good is an advanced indexing mail client if we don't know how to
5 use it to actually find e-mail?
7 The [[notmuch-search-terms manual page|manpages/notmuch-search-terms-7]] should
8 cover everything in a fairly concise manner. Please refer to that for any
11 Notmuch uses the [Xapian](http://xapian.org/) search engine. The [Xapian
12 QueryParser](http://xapian.org/docs/queryparser.html) documentation has
13 a generic description of the search language. The intended audience is
14 developers wanting to use Xapian in their applications; this page
15 attempts to explain it to users of Notmuch.
19 See the [Wikipedia article](http://en.wikipedia.org/wiki/Stemming) for
20 the detailed description. What this means for us is that these searches
22 notmuch search detailed
23 notmuch search details
26 will all return identical results, because Xapian first "reduces" the
27 term to the common stem (here 'detail') and then performs the search.
29 The only way to turn this off is the so called search for proper names:
30 a search for a capitalized word will be performed unstemmed, so that one
31 can search for "John" and not get results for "Johnson".
33 ### Languages other than English
35 Stemming is currently only supported for English. Words in other
36 languages will be performed unstemmed unless somebody teaches Xapian how
37 to perform stemming for that language.
41 (how is the QueryParser configured?)
45 It is possible to use a trailing '\*' as a wildcard. A search for
46 'wildc\*' will match 'wildcard', 'wildcat', etc.
50 Xapian implements the usual operators and a few more that are
51 useful when searching e-mails.
53 *Note: The operators need not be capitalized for notmuch, so 'NOT' and 'not' are
54 equivalent. The capitalized form is used below only for readability*
60 will only return results that contain 'term1'.
64 will return results that do not contain 'term2'. '+' and '-' can also be
65 used on bracketed expressions or phrases (see below).
69 notmuch search term1 AND term2
71 will return results that contain **both** 'term1' and 'term2'.
73 If no explicit operator is provided all search terms are connected by an
74 implicit AND, so these two searches:
76 notmuch search term1 AND term2
77 notmuch search term1 term2
81 notmuch search term1 NOT term2
83 will return results that contain 'term1' but do not contain 'term2'. For
84 a query that looks more like natural language you can also use AND NOT
86 notmuch search term1 AND NOT term2
88 ### XOR (exclusive OR)
90 notmuch search term1 XOR term2
92 will return results that contain either 'term1' or 'term2', but **not**
97 notmuch search term1 OR term2
99 will return results that contain either 'term1' or 'term2'.
103 Operators above are listed in the default order of precedence. One can
104 override the precedence using bracketed expressions:
106 notmuch search term1 AND term2 OR term3
110 notmuch search (term1 AND term2) OR term3
114 notmuch search term1 AND (term2 OR term3)
118 notmuch search term1 NEAR term2
120 will return results where term1 is within 10 words of term2. The threshold
121 can be set like this:
123 notmuch search term1 NEAR/2 term2
127 notmuch search term1 ADJ term2
129 will return results where term1 is within 10 words of term2, but in the
130 same order as in the query. The threshold can be set the same as with NEAR:
132 notmuch search term1 ADJ/7 term2
136 According to the Xapian documentation a phrase surrounded with double
137 quotes (like this: "my phrase") will return results that match
138 everything containing "that exact phrase", but hyphenated words or
139 e-mail addresses are also treated as phrases.
141 In practice this means that these two searches are **not** equivalent:
143 notmuch search "Debian Project"
144 notmuch search Debian ADJ/1 Project
148 You can search your collection by using several prefixes, like this:
150 notmuch search from:john
152 This will return results where 'john' appears in the name or the e-mail
153 address. See 'notmuch help search-terms' for a complete list of
158 An important concept for notmuch is the Message-Id, which is a unique
159 identifier for each message. Individual messages can be accessed via
160 their message ID with the "id:" prefix:
162 notmuch search id:<message-id>
166 Since notmuch is about (large) e-mail collections it is very useful to
167 be able to search for e-mails within a specific date range. This will
170 notmuch search date:<since>..<until>
172 For `<since>` and `<until>`, notmuch understands a variety of standard
173 and natural ways of expressing dates and times, both in absolute terms
174 ("2012-10-24") and in relative terms ("yesterday"). Please refer to the
175 [[notmuch-search-terms manual page|manpages/notmuch-search-terms-7]] for