unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: Olly Betts <olly@survex.com>, James Aylett <james@tartarus.org>
Cc: notmuch@notmuchmail.org, xapian-discuss@lists.xapian.org
Subject: Re: xapian parser bug?
Date: Sun, 30 Sep 2018 14:49:49 -0300	[thread overview]
Message-ID: <87o9cekh8i.fsf@tethera.net> (raw)
In-Reply-To: <87y3bj198a.fsf@tethera.net>

David Bremner <david@tethera.net> writes:

> Olly Betts <olly@survex.com> writes:
>
>>
>> FWIW, I also couldn't reproduce this (I tried with quest and 1.4.7):
>>
>> $ quest -psubject:S -fdefault,boolean_any_case 'subject:"and"'
>> Parsed Query: Query(Sand@1)
>>
>
> Ah, OK, it must have something to do with the way that notmuch is using
> field processors. And I see now that the following code (from
> lib/regexp-fields.cc) is probably related (at least it explains
> subject:" not" works)
>
>             if (str.find (' ') != std::string::npos)
> 		query_str = '"' + str + '"';
> 	    else
> 		query_str = str;
>
> 	    return parser.parse_query (query_str, NOTMUCH_QUERY_PARSER_FLAGS, term_prefix);

For the record, I have proposed a fix for notmuch (str is known to be
non-empty there). This will phrase quote by default, unless the string
looks like a wildcard query (without spaces).

diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc
index 084bc8c0..52f30d82 100644
--- a/lib/regexp-fields.cc
+++ b/lib/regexp-fields.cc
@@ -194,7 +194,7 @@ RegexpFieldProcessor::operator() (const std::string & str)
             * phrase parsing, when possible */
            std::string query_str;
 
-           if (str.find (' ') != std::string::npos)
+           if (*str.rbegin () != '*' || str.find (' ') != std::string::npos)
                query_str = '"' + str + '"';
            else

  reply	other threads:[~2018-09-30 17:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-29 22:09 xapian parser bug? David Bremner
2018-09-30  8:50 ` James Aylett
2018-09-30  9:20   ` Olly Betts
2018-09-30 12:05     ` David Bremner
2018-09-30 17:49       ` David Bremner [this message]
2018-09-30 20:43       ` Olly Betts
2018-10-01  1:25         ` 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=87o9cekh8i.fsf@tethera.net \
    --to=david@tethera.net \
    --cc=james@tartarus.org \
    --cc=notmuch@notmuchmail.org \
    --cc=olly@survex.com \
    --cc=xapian-discuss@lists.xapian.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).