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: Strange, incoherent query parsing
Date: Thu, 29 Aug 2019 21:13:17 -0300	[thread overview]
Message-ID: <871rx38q8y.fsf@tethera.net> (raw)
In-Reply-To: <874l21wc9w.fsf@disroot.org>

Jorge P. de Morais Neto <jorge+list@disroot.org> writes:

> Hello,
>
> Em 2019-08-28T07:08:28-0300, David Bremner escreveu:
>
>> I don't know about the other cases but here there is an  extra closing
>> ')', which confuses the query parser.  I agree that an error report
>> would be nicer, but we don't currently have that option from Xapian.
>
> Oops.  Sorry about that.  But still there seem to be real errors.  The
> first query[1] should match messages containing both "Saúde" and "Geap"
> (sans the double quotes) in the subject, but does not.
>
> 1: 'subject:("Saúde" "Geap") OR subject:xplitz'

There's two problems here. The first is because of the way regexp fields
are implimented subject: doesn't tolerate the unescaped/unquoted space.
So you'd have to write  'subject:"(Saúde Geap)"' to get anything sensible.

The other problem is that are treating the part within () as a quoted
phrase, which is not correct.

If you can build from source try the patch below [1]. With it, I think

   notmuch count 'subject:"(Saúde Geap)" OR subject:xplitz'

should behave more like what you want. Notice my use of quotes is bit
different that your original query.

>
> Also note that the fourth query[2] should have AND as the implicit
> boolean operator, because 'subject:' is not a boolean prefix.  You
> explained in the other thread the implicit OR operator only applies for
> search terms with the same /boolean/ prefix.

Yes, this is the same problem as in your other report. I posted some
patches that should fix it, but they need more testing.

[1]:

diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc
index 198eb32f..858b1e24 100644
--- a/lib/regexp-fields.cc
+++ b/lib/regexp-fields.cc
@@ -189,6 +189,13 @@ RegexpFieldProcessor::operator() (const std::string & str)
        } else {
            throw Xapian::QueryParserError ("unmatched regex delimiter in '" + str + "'");
        }
+    }  else if (str.at (0) == '(') {
+       if (str.length () > 1 && str.at (str.size () - 1) == ')') {
+           std::string subexp_str = str.substr (1, str.size () - 2);
+           return parser.parse_query (subexp_str, NOTMUCH_QUERY_PARSER_FLAGS, term_prefix);
+       } else {
+           throw Xapian::QueryParserError ("unmatched '(' in '" + str + "'");
+       }
     } else {
        if (options & NOTMUCH_FIELD_PROBABILISTIC) {
            /* TODO replace this with a nicer API level triggering of

      reply	other threads:[~2019-08-30  0:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 17:38 Strange, incoherent query parsing Jorge P. de Morais Neto
2019-08-28 10:08 ` David Bremner
2019-08-28 15:16   ` Jorge P. de Morais Neto
2019-08-30  0:13     ` David Bremner [this message]

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=871rx38q8y.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).