unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: "Jorge P. de Morais Neto" <jorge+list@disroot.org>,
	notmuch@notmuchmail.org
Subject: Re: Apparently, terms with a common prefix are *not* connected by implicit "OR"
Date: Tue, 20 Aug 2019 22:39:03 -0300	[thread overview]
Message-ID: <875zmrpaa0.fsf@tethera.net> (raw)
In-Reply-To: <87lfvucw6d.fsf@disroot.org>

Jorge P. de Morais Neto <jorge+list@disroot.org> 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).

  reply	other threads:[~2019-08-21  1:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-11 17:20 Apparently, terms with a common prefix are *not* connected by implicit "OR" Jorge P. de Morais Neto
2019-08-11 23:08 ` David Bremner
2019-08-15 14:58   ` Jorge P. de Morais Neto
2019-08-21  1:39     ` David Bremner [this message]
2019-08-21  5:48       ` Rollins, Jameson
2019-08-21 11:41         ` WIP: fix implicit operators David Bremner
2019-08-21 11:41           ` [PATCH 1/3] test: add known broken tests for from: and subject: David Bremner
2019-08-25  9:33             ` Tomi Ollila
2019-08-21 11:41           ` [PATCH 2/3] lib: introduce N_F_GROUP and use it to fix implicit AND for from: David Bremner
2019-08-21 11:41           ` [PATCH 3/3] WIP/test: extend field grouping tests David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875zmrpaa0.fsf@tethera.net \
    --to=david@tethera.net \
    --cc=jorge+list@disroot.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).