1 .. _notmuch-sexp-queries(7):
10 **notmuch** **search** ``--query=sexp`` '(and (to santa) (date december))'
19 An *s-expression* is either an atom, or list of whitespace delimited
20 s-expressions inside parentheses. Atoms are either
23 A basic value is an unquoted string containing no whitespace, double quotes, or
27 Double quotes (") delimit strings possibly containing whitespace
28 or parentheses. These can contain double quote characters by
29 escaping with backslash. E.g. ``"this is a quote \""``.
34 An s-expression query is either an atom, the empty list, or a
35 *compound query* consisting of a prefix atom (first element) defining
36 a *field*, *logical operation*, or *modifier*, and 0 or more
43 Match all messages containing *term*, possibly after
44 stemming or phase splitting. For discussion of stemming in
45 notmuch see :any:`notmuch-search-terms(7)`. Stemming only applies
46 to unquoted terms (basic values) in s-expression queries.
48 ``(`` *field* |q1| |q2| ... |qn| ``)``
49 Restrict the queries |q1| to |qn| to *field*, and combine with *and*
50 (for most fields) or *or*. See :any:`fields` for more information.
52 ``(`` *operator* |q1| |q2| ... |qn| ``)``
53 Combine queries |q1| to |qn|. Currently supported operators are
54 ``and``, ``or``, and ``not``. ``(not`` |q1| ... |qn| ``)`` is equivalent
55 to ``(and (not`` |q1| ``) ... (not`` |qn| ``))``.
57 ``(`` *modifier* |q1| |q2| ... |qn| ``)``
58 Combine queries |q1| to |qn|, and reinterpret the result (e.g. as a regular expression).
59 See :any:`modifiers` for more information.
66 *Fields* (also called *prefixes* in notmuch documentation)
67 correspond to attributes of mail messages. Some are inherent (and
68 immutable) like ``subject``, while others ``tag`` and ``property`` are
69 settable by the user. Each concrete field in
70 :any:`the table below <field-table>`
71 is discussed further under "Search prefixes" in
72 :any:`notmuch-search-terms(7)`. The row *user* refers to user defined
73 fields, described in :any:`notmuch-config(1)`.
77 .. table:: Fields with supported modifiers
79 +------------+-----------+-----------+-----------+-----------+----------+
80 | field | combine | type | expand | wildcard | regex |
81 +============+===========+===========+===========+===========+==========+
82 | *none* | and | | no | yes | no |
83 +------------+-----------+-----------+-----------+-----------+----------+
84 | *user* | and | phrase | no | yes | no |
85 +------------+-----------+-----------+-----------+-----------+----------+
86 | attachment | and | phrase | yes | yes | no |
87 +------------+-----------+-----------+-----------+-----------+----------+
88 | body | and | phrase | no | no | no |
89 +------------+-----------+-----------+-----------+-----------+----------+
90 | date | | range | no | no | no |
91 +------------+-----------+-----------+-----------+-----------+----------+
92 | folder | or | phrase | yes | yes | yes |
93 +------------+-----------+-----------+-----------+-----------+----------+
94 | from | and | phrase | yes | yes | yes |
95 +------------+-----------+-----------+-----------+-----------+----------+
96 | id | or | term | no | yes | yes |
97 +------------+-----------+-----------+-----------+-----------+----------+
98 | is | and | term | yes | yes | yes |
99 +------------+-----------+-----------+-----------+-----------+----------+
100 | lastmod | | range | no | no | no |
101 +------------+-----------+-----------+-----------+-----------+----------+
102 | mid | or | term | no | yes | yes |
103 +------------+-----------+-----------+-----------+-----------+----------+
104 | mimetype | or | phrase | yes | yes | no |
105 +------------+-----------+-----------+-----------+-----------+----------+
106 | path | or | term | yes | yes | yes |
107 +------------+-----------+-----------+-----------+-----------+----------+
108 | property | and | term | yes | yes | yes |
109 +------------+-----------+-----------+-----------+-----------+----------+
110 | subject | and | phrase | yes | yes | yes |
111 +------------+-----------+-----------+-----------+-----------+----------+
112 | tag | and | term | yes | yes | yes |
113 +------------+-----------+-----------+-----------+-----------+----------+
114 | thread | or | term | yes | yes | yes |
115 +------------+-----------+-----------+-----------+-----------+----------+
116 | to | and | phrase | yes | yes | no |
117 +------------+-----------+-----------+-----------+-----------+----------+
128 Match all messages containing the word "wizard", ignoring case.
131 Match all messages containing "added", but also those containing "add", "additional",
132 "Additional", "adds", etc... via stemming.
135 Match messages containing words "Bob" and "Marley", or their stems
136 The words need not be adjacent.
139 Match messages containing neither "Bob" nor "Marley", nor their stems,
141 ``(subject quick "brown fox")``
142 Match messages whose subject contains "quick" (anywhere, stemmed) and
143 the phrase "brown fox".
145 .. |q1| replace:: :math:`q_1`
146 .. |q2| replace:: :math:`q_2`
147 .. |qn| replace:: :math:`q_n`