On properties and the notmuch CLI

David Bremner david at tethera.net
Sun Feb 17 16:25:25 PST 2019


Matt Armstrong <marmstrong at google.com> writes:

>  (c) it is not possible to set or modify properties from the command
>  line.

>
> True?  Are queries like these any more efficient than tag doing a prefix
> regex search over tags?  By this I mean, does the Xapian side keep an
> efficient index of all messages that have at least one property "P"?

It's pretty much the same (or would be, if implimented).  Properties are
stored as xapian terms attached to mail document.  This means there is a
sorted list of P=a, P=b, etc..., we can jump efficiently to the first
one, and construct a query that matches them all. It does mean if you
have an enormous number of values for one property it will be
expensive.  Xapian has support for "wildcard" terms ending in "*".
If I remember correctly this is not supported for boolean ("exact")
prefixes like property: and tag: ; internally this does something
similar, although quite possibly a bit faster since it's internal to
Xapian (and written by Xapian experts).

> Second, a question: is there any possibility of relaxing restriction
> (c)

It's possible. It would require a bit of coding (roughly duplicating
notmuch-tag.c, but with a simpler command line syntax, I suppose). It
could be a bit of a footgun since e.g. notmuch is using some properties
to maintain encryption state. But people can already make themselves sad
with mass tag operations.

> As far as the risk of property name collisions, perhaps encourage an
> x-<project>- prefix convention for all properties not registered with
> the notmuch project?  That seems to have served well enough for email
> headers.

BTW, notmuch is currently using . as a namespace separator, so this
would look more like "x-project." .  Your proposal seems plausible to
me; if others agree we can document it.


More information about the notmuch mailing list