On 2026-01-28, David Bremner wrote:
> 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.

Essentially it's a current limitation of the parser.

Originally `NOT` and `-` (which Xapian calls "HATE" in this context,
c.f. `+` is called "LOVE") both required a subquery to work against -
you couldn't just invert a whole query.  The reason for this was that
older versions of Xapian (1.0.x and older) couldn't run such a query
efficiently (except in the special case where there are no gaps in the
document ID numbering, which is typically only true if you've never
deleted a document).

The chert backend in 1.2.x can support this reasonably efficiently in
the general case, and FLAG_PURE_NOT (which notmuch enables) was added
to allow enabling this for `NOT`.  There was some discussion at the time
as to whether this should cover `-` too, or if we should also add
`FLAG_PURE_HATE`, but there didn't seem such a very compelling reason to
do either - we'd had user requests for supporting pure `NOT`, but not
for HATE.

> > thread:0000000000003cf0 and ( -from:mailer-daemon )

The `-` here is treated as pure HATE because the subquery inside the
parentheses is parsed much like a top-level query, which isn't a
case we considered back then.

I think this ought to be addressed in Xapian and have opened a ticket:

https://trac.xapian.org/ticket/849

For now you'll need to use `NOT` instead as bremner suggests:

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

Cheers,
    Olly

_______________________________________________
notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to