[PATCH] add has: query prefix to search for specific properties

Daniel Kahn Gillmor dkg at fifthhorseman.net
Sun Jul 17 16:44:27 PDT 2016


On Sun 2016-07-17 02:39:53 +0200, David Bremner wrote:
> Daniel Kahn Gillmor <dkg at fifthhorseman.net> writes:
>
>> We want to be able to query the properties directly, like:
>>
>>    notmuch count has:foo=bar
>>
>> which should return a count of messages where the property with key
>> "foo" has value equal to "bar".
>>
>> This patch could be improved:
>>
>> If no = sign is present (e.g. "has:foo"), it'd be nice to just match
>>  on every message that has property "foo", regardless of value.
>
> At the moment I can't think of a nice easy way to do this.  It could do
> something like that proposed for "tag:*", namely expand it internally
> into an or query, by traversing the
> db->allterms_begin("XPROPERTY"). 
>
>> It would also be good to include some tests.
>
> and update notmuch-search-terms(7) ?

yes, please -- patches welcome ;)

an attempt to describe the distinction between "tags" and "properties":

Tags are user-settable and user-fetchable, and automated systems are
discouraged from adding them (we have some legacy exceptions like
"inbox" and "unread" and "signed" and "encrypted").  Tags are generally
expected to be simple textual labels.

Properties are user-fetchable, but should only be set by automated
systems.  Properties are key=value pairs (though a given message can
have any number of properties with the same key), and while the key is
expected to be a textual string (printable characters except for "=")
and the value can potentially be arbitrary binary data.

I welcome edits on this text if it doesn't capture your current sense of
the distinction.

     --dkg


More information about the notmuch mailing list