[ http://issues.apache.org/jira/browse/LUCENE-573?page=all ]
Michael Busch updated LUCENE-573: --------------------------------- Attachment: escaped_quotes_inside_phrases.patch Tomislav, 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() method: (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. Michael > Escaped quotes inside a phrase cause a ParseException > ----------------------------------------------------- > > Key: LUCENE-573 > URL: http://issues.apache.org/jira/browse/LUCENE-573 > 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: > http://www.nabble.com/ParseException-with-escaped-quotes-in-a-phrase-t1647115.html -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]