Re: Adding parentheses inverts query

Subject: Re: Adding parentheses inverts query

Date: Wed, 28 Jan 2026 10:09:32 +0900

To: Ackerley Tng, notmuch@notmuchmail.org

Cc:

From: David Bremner


Ackerley Tng <ackerleytng@google.com> writes:

> Hi!
>
> I'm trying to show all the emails in a thread, but filter out all the
> failed delivery reports:
>
> This shows nothing as expected:
>
> notmuch show --exclude=false --entire-thread=false '
> thread:0000000000003cf0 and -from:mailer-daemon ' | grep mailer
>
> But this still shows all the delivery reports
>
> notmuch show --exclude=false --entire-thread=false '
> thread:0000000000003cf0 and ( -from:mailer-daemon ) ' | grep mailer
>

I have never used the - prefix, but it seems like it only works directly
after the 'and'. I'm not sure if this is a limitation of the Xapian
parser or something about how notmuch calls it. As far as I can tell
"-from:mailer-daemon" alone doesn't really work either (the leading - is
just ignored).

In general try setting "NOTMUCH_DEBUG_QUERY=y" in the environment and
you will get some hints about the query parsing. This led me to

    'thread:0000000000003cf0 and ( not from:mailer-daemon )'

which seems to be parsed in a more sensible way.

I don't know your use case, but if constructing queries by machine I
recommend investigating notmuch-sexp-queries(7).


_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: