From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id B57E76DE0E83 for ; Tue, 20 Aug 2019 18:39:10 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.052 X-Spam-Level: X-Spam-Status: No, score=-0.052 tagged_above=-999 required=5 tests=[AWL=-0.051, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C37sPR3s0CcG for ; Tue, 20 Aug 2019 18:39:08 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 90D746DE0C32 for ; Tue, 20 Aug 2019 18:39:08 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1i0Faa-0000WA-9X; Tue, 20 Aug 2019 21:39:04 -0400 Received: (nullmailer pid 18284 invoked by uid 1000); Wed, 21 Aug 2019 01:39:03 -0000 From: David Bremner To: "Jorge P. de Morais Neto" , notmuch@notmuchmail.org Subject: Re: Apparently, terms with a common prefix are *not* connected by implicit "OR" In-Reply-To: <87lfvucw6d.fsf@disroot.org> References: <87lfvzipp5.fsf@disroot.org> <87ef1ri9kl.fsf@tethera.net> <87lfvucw6d.fsf@disroot.org> Date: Tue, 20 Aug 2019 22:39:03 -0300 Message-ID: <875zmrpaa0.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Aug 2019 01:39:10 -0000 Jorge P. de Morais Neto writes: > [ I had replied to David Bremner alone so I didn't have to worry about > private information leakage. But now I decided to clean the private > information and reply to the list too. ] > > Em 2019-08-11T20:08:58-0300, David Bremner escreveu: >> Thanks for the report. As a test, can you try with >> >> $ notmuch count '(to:pontodosconcursos.com.br to:"jorge+cp+concurso@disroot.org")' >> >> I suspect that will work around the problem, which I believe is related >> to the way that notmuch uses the xapian parser (in order to provide >> regexp matching for some prefixes). In particular, if I try that with >> NOTMUCH_DEBUG_QUERY=yes in the environment I can see the implicit OR. Thanks for the detailed report. There are (at least) two different things going on (in addition to the strange expansion that I focussed on before, but seems not to be the most important issue). One is that the combining with implicit-OR was only intended to work for "boolean prefixes" like tag:. So this is a documentation bug. A second thing is due to some implimentation details in notmuch, from: was being treated (for purposes of combining) as a filter. I think it's clear we want from: and to: to behave similarly, so I propose the following patch diff --git a/lib/database.cc b/lib/database.cc index 24b7ec43..4db1b465 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -400,7 +400,7 @@ _setup_query_field (const prefix_t *prefix, notmuch_database_t *notmuch) /* we treat all field-processor fields as boolean in order to get the raw input */ if (prefix->prefix) notmuch->query_parser->add_prefix ("", prefix->prefix); - notmuch->query_parser->add_boolean_prefix (prefix->name, fp); + notmuch->query_parser->add_boolean_prefix (prefix->name, fp, !(prefix->flags & NOTMUCH_FIELD_PROBABILISTIC)); } else { _setup_query_field_default (prefix, notmuch); } This will make to:a to:b and from:a from:b expand as to:a AND to:b and from:a AND from:b I don't think it's possible to have to:a to:b expand to to:a OR to:b without also having a b expand to a OR b which I think most people would find surprising. At the moment I'm not sure I see the benefit of having tag: combine with implicit OR (other than being slightly easier to document).