? at beginning of prefixed field

David Bremner david at tethera.net
Fri Mar 13 00:02:44 GMT 2026


I have been playing with the new query parser FLAG_WILDCARD_GLOB, and i
have a some unexpected behaviour. As you might remember there is a
fairly messy set of field processors in notmuch, but 'to:' should be a
regular probabilistic field.

If I try a ? in the middle of a prefixed word, it seems to work fine.

    % NOTMUCH_DEBUG_QUERY=t ./notmuch count 'to:b?emner'
    Query string is:
    to:b?emner
    Exclude query is:
    Query((((Kspam OR Kdeleted) OR Kmuted) OR Kbad-address))
    Final query is:
    Query(((Tmail AND WILDCARD SYNONYM XTOb?emner) AND_NOT (((Kspam OR Kdeleted) OR Kmuted) OR Kbad-address)))
    131948

That number matches to:bremner

On the other hand if I put the ? at the front of the word,
it seems like the query parser is failing and falling back
to an unprefixed search

    % NOTMUCH_DEBUG_QUERY=t ./notmuch count 'to:?remner'
    Query string is:
    to:?remner
    Exclude query is:
    Query((((Kspam OR Kdeleted) OR Kmuted) OR Kbad-address))
    Final query is:
    Query(((Tmail AND ((Zto at 1 OR ZGto at 1 OR ZKto at 1 OR ZQto at 1 OR ZPto at 1 OR ZXPROPERTYto at 1 OR ZXFOLDER:to at 1 OR ZXFROMto at 1 OR ZXTOto at 1 OR ZXATTACHMENTto at 1 OR ZXMIMETYPEto at 1 OR ZXSUBJECTto at 1 OR ZXUList:to at 1) AND (WILDCARD OR ?remner SYNONYM WILDCARD OR G?remner SYNONYM WILDCARD OR K?remner SYNONYM WILDCARD OR Q?remner SYNONYM WILDCARD OR P?remner SYNONYM WILDCARD OR XPROPERTY?remner SYNONYM WILDCARD OR XFOLDER:?remner SYNONYM WILDCARD OR XFROM?remner SYNONYM WILDCARD OR XTO?remner SYNONYM WILDCARD OR XATTACHMENT?remner SYNONYM WILDCARD OR XMIMETYPE?remner SYNONYM WILDCARD OR XSUBJECT?remner SYNONYM WILDCARD OR XUList:?remner))) AND_NOT (((Kspam OR Kdeleted) OR Kmuted) OR Kbad-address)))
    157728

This is all with libxapian-dev 1.5.1-1 

If you want to experiment

   git clone https://git.notmuchmail.org/git/notmuch -b feature/wildcard


David



More information about the Xapian-discuss mailing list