Index: src/test/org/apache/lucene/queryParser/TestQueryParser.java =================================================================== --- src/test/org/apache/lucene/queryParser/TestQueryParser.java (revision 515495) +++ src/test/org/apache/lucene/queryParser/TestQueryParser.java (working copy) @@ -522,6 +522,8 @@ //assertQueryEquals("foo \\|| bar", a, "foo \\|| bar"); //assertQueryEquals("foo \\AND bar", a, "foo \\AND bar");*/ + assertQueryEquals("\\a", a, "a"); + assertQueryEquals("a\\-b:c", a, "a-b:c"); assertQueryEquals("a\\+b:c", a, "a+b:c"); assertQueryEquals("a\\:b:c", a, "a:b:c"); @@ -585,6 +587,15 @@ assertQueryEquals("XY\\u005", a, "XYZ"); fail("ParseException expected, not thrown"); } catch (ParseException expected) {} + + // Tests bug LUCENE-800 + assertQueryEquals("(item:\\\\ item:ABCD\\\\)", a, "item:\\ item:ABCD\\"); + assertQueryEquals("\\*", a, "*"); + assertQueryEquals("\\\\", a, "\\"); // escaped backslash + try { + assertQueryEquals("\\", a, "\\"); + fail("ParseException expected not thrown (backslash must be escaped)"); + } catch (ParseException expected) {} } public void testQueryStringEscaping() throws Exception { Index: src/test/org/apache/lucene/search/TestWildcard.java =================================================================== --- src/test/org/apache/lucene/search/TestWildcard.java (revision 515495) +++ src/test/org/apache/lucene/search/TestWildcard.java (working copy) @@ -170,13 +170,13 @@ QueryParser qp = new QueryParser(field, new WhitespaceAnalyzer()); qp.setAllowLeadingWildcard(true); String docs[] = { - "abcdefg1", - "hijklmn1", - "opqrstu1", + "\\ abcdefg1", + "\\79 hijklmn1", + "\\\\ opqrstu1", }; // queries that should find all docs String matchAll[] = { - "*", "*1", "**1", "*?", "*?1", "?*1", "**", "***", + "*", "*1", "**1", "*?", "*?1", "?*1", "**", "***", "\\\\*" }; // queries that should find no docs String matchNone[] = { @@ -184,9 +184,9 @@ }; // queries that should be parsed to prefix queries String matchOneDocPrefix[][] = { - {"a*", "ab*", "abc*"}, // these should find only doc 0 - {"h*", "hi*", "hij*"}, // these should find only doc 1 - {"o*", "op*", "opq*"}, // these should find only doc 2 + {"a*", "ab*", "abc*", }, // these should find only doc 0 + {"h*", "hi*", "hij*", "\\\\7*"}, // these should find only doc 1 + {"o*", "op*", "opq*", "\\\\\\\\*"}, // these should find only doc 2 }; // queries that should be parsed to wildcard queries String matchOneDocWild[][] = { @@ -200,7 +200,7 @@ IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer()); for (int i = 0; i < docs.length; i++) { Document doc = new Document(); - doc.add(new Field(field,docs[i],Store.NO,Index.UN_TOKENIZED)); + doc.add(new Field(field,docs[i],Store.NO,Index.TOKENIZED)); iw.addDocument(doc); } iw.close();