help wanted: "notmuch count property:foo" as distinct from "notmuch count property:foo=bar"
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Tue Jan 17 12:31:52 PST 2017
in lib/database.cc, we have this FIXME in a comment:
* Mail document
* A mail document is associated with a particular email message. It
* is stored in one or more files on disk (though only one has its
* content indexed) and is uniquely identified by its "id" field
* (which is generally the message ID). It is indexed with the
* following prefixed terms which the database uses to construct
* threads, etc.:
* Multiple terms of given prefix:
* property: Has a property with key=value
* FIXME: if no = is present, should match on any value
If we had it resolved, other improvments i'd like to make to notmuch
would be significantly easier to test!
I've been looking at trying to fix this FIXME by analogy with either our
special nifty date: handler, or by analogy with the re: handlers
introduced in id:20161114214651.19770-1-david at tethera.net, but my
xapian-fu doesn't appear to be up to the task at the moment.
The date: handler appears to rely on some xapian magic to be able to
handle both date:$DAY and date:$FIRSTDAY..$SECONDDAY (that is, deciding
how to query based on the presence or absence of "..", as we'd want to
do with "=" in the property: query)
And the re: handlers allow different styles of searching a field, but
they use a distinct prefix for their queries (it would be good to just
keep it to "property:" in both cases).
So, to be clear, searching for:
* property:foo would give a hit on any message that had property "foo"
set to anything.
* property:foo=bar would tive a hit on any message that had property
"foo" set to *exactly* "bar".
* in particular, property:foo= would give a hit on anything that had
property "foo" set to the empty string.
Bremner was very helpful on #notmuch, pointed me to the above message,
and suggested the basic outlines of a fix but his help still wasn't
enough for me to figure out the right way to clear this FIXME.
I'd welcome more help in resolving this. For someone who understands
Xapian's query parser and how notmuch is using it, i'm imagining this
wouldn't be a lot of work. I'm happy to test and review any patches.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 832 bytes
Desc: not available
More information about the notmuch