Re: xapian parser bug?

David Bremner <[email protected]>
Newsgroups gmane.mail.notmuch.general,gmane.comp.search.xapian.general
Message-ID <[email protected]>
David Bremner <[email protected]> writes:

> Olly Betts <[email protected]> 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
_______________________________________________
notmuch mailing list
[email protected]
https://notmuchmail.org/mailman/listinfo/notmuch
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.