lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Busch (JIRA)" <>
Subject [jira] Updated: (LUCENE-573) Escaped quotes inside a phrase cause a ParseException
Date Mon, 07 Aug 2006 22:22:15 GMT
     [ ]

Michael Busch updated LUCENE-573:

    Attachment: escaped_quotes_inside_phrases.patch


thanks for finding this problem in the queryparser. I attach a patch file that fixes this
bug. Now the queryparser does not recognize an escaped quote inside a phrase as the phrase
terminator anymore. 

I also updated the testcase org.apache.lucene.queryParser.TestQueryParser to test escaped
quotes within phrases. This testcase fails with the old version of the queryparser and runs
successful with the patched version. I added the following three tests to the testEscaped()

(1)    assertQueryEquals("a \\\"b c\\\" d", a, "a \"b c\" d");
(2)    assertQueryEquals("\"a \\+b c d\"", a, "\"a \\+b c d\"");
(3)    assertQueryEquals("\"a \\\"b c\\\" d\"", a, "\"a \\\"b c\\\" d\""); 
Please notice that (3) is different from your second suggested assert. You assume that the
queryparser unescapes the quotes inside the phrase, but the queryparser does not unescape
*any* escaped characters inside a phrase. You can see that in (2), where the escaped + (plus)
character does not become unescaped.


> Escaped quotes inside a phrase cause a ParseException
> -----------------------------------------------------
>                 Key: LUCENE-573
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: QueryParser
>    Affects Versions: 1.9
>         Environment: Debian Sarge, Sun JDK 1.4.2
>            Reporter: Tomislav Gountchev
>            Priority: Minor
>         Attachments: escaped_quotes_inside_phrases.patch
> QueryParser cannot handle escaped quotes when inside a phrase. Escaped quotes not in
a phrase are not a problem. This can be added to TestQueryParser.testEscaped() to demonstrate
the issue - the second assert throws an exception:
> assertQueryEquals("a \\\"b c\\\" d", a, "a \"b c\" d");
> assertQueryEquals("\"a \\\"b c\\\" d\"", a, "\"a \"b c\" d\"");
> See also this thread:

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message