? at beginning of prefixed field

David Bremner <[email protected]> Fri, 13 Mar 2026 09:02:44 +0900
Newsgroups gmane.comp.search.xapian.general
Message-ID <[email protected]>
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@1 OR ZGto@1 OR ZKto@1 OR ZQto@1 OR ZPto@1 OR ZXPROPERTYto@1 OR ZXFOLDER:to@1 OR ZXFROMto@1 OR ZXTOto@1 OR ZXATTACHMENTto@1 OR ZXMIMETYPEto@1 OR ZXSUBJECTto@1 OR ZXUList:to@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