qp accept empty string: LUCENE-1006

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@580584 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2007-09-29 14:10:56 +00:00
parent 014f23033f
commit 16342bedb9
4 changed files with 22 additions and 24 deletions

View File

@ -1,4 +1,4 @@
Lucene Change Log Lucene Change Log
$Id$ $Id$
@ -110,6 +110,9 @@ Bug fixes
This bug was introduced with LUCENE-843. (Grant Ingersoll via This bug was introduced with LUCENE-843. (Grant Ingersoll via
Mike McCandless) Mike McCandless)
16. LUCENE-1006: Fixed QueryParser to accept a "" field value (zero
length quoted string.) (yonik)
New features New features
1. LUCENE-906: Elision filter for French. 1. LUCENE-906: Elision filter for French.

View File

@ -888,7 +888,7 @@ PARSER_END(QueryParser)
| <COLON: ":" > | <COLON: ":" >
| <STAR: "*" > | <STAR: "*" >
| <CARAT: "^" > : Boost | <CARAT: "^" > : Boost
| <QUOTED: "\"" (~["\""] | "\\\"")+ "\""> | <QUOTED: "\"" (~["\""] | "\\\"")* "\"">
| <TERM: <_TERM_START_CHAR> (<_TERM_CHAR>)* > | <TERM: <_TERM_START_CHAR> (<_TERM_CHAR>)* >
| <FUZZY_SLOP: "~" ( (<_NUM_CHAR>)+ ( "." (<_NUM_CHAR>)+ )? )? > | <FUZZY_SLOP: "~" ( (<_NUM_CHAR>)+ ( "." (<_NUM_CHAR>)+ )? )? >
| <PREFIXTERM: ("*") | ( <_TERM_START_CHAR> (<_TERM_CHAR>)* "*" ) > | <PREFIXTERM: ("*") | ( <_TERM_START_CHAR> (<_TERM_CHAR>)* "*" ) >

View File

@ -142,7 +142,7 @@ private final int jjMoveNfa_3(int startState, int curPos)
kind = 6; kind = 6;
} }
else if (curChar == 34) else if (curChar == 34)
jjCheckNAddTwoStates(15, 17); jjCheckNAddStates(0, 2);
else if (curChar == 33) else if (curChar == 33)
{ {
if (kind > 9) if (kind > 9)
@ -152,7 +152,7 @@ private final int jjMoveNfa_3(int startState, int curPos)
{ {
if (kind > 18) if (kind > 18)
kind = 18; kind = 18;
jjCheckNAddStates(0, 4); jjCheckNAddStates(3, 7);
} }
else if (curChar == 42) else if (curChar == 42)
{ {
@ -175,16 +175,13 @@ private final int jjMoveNfa_3(int startState, int curPos)
kind = 9; kind = 9;
break; break;
case 14: case 14:
case 16:
if (curChar == 34) if (curChar == 34)
jjCheckNAddTwoStates(15, 17); jjCheckNAddStates(0, 2);
break; break;
case 15: case 15:
if ((0xfffffffbffffffffL & l) != 0L) if ((0xfffffffbffffffffL & l) != 0L)
jjCheckNAddStates(5, 7); jjCheckNAddStates(0, 2);
break;
case 16:
if (curChar == 34)
jjCheckNAddStates(5, 7);
break; break;
case 18: case 18:
if (curChar == 34 && kind > 17) if (curChar == 34 && kind > 17)
@ -229,7 +226,7 @@ private final int jjMoveNfa_3(int startState, int curPos)
break; break;
if (kind > 18) if (kind > 18)
kind = 18; kind = 18;
jjCheckNAddStates(0, 4); jjCheckNAddStates(3, 7);
break; break;
case 29: case 29:
if ((0x7bfff8f8ffffd9ffL & l) == 0L) if ((0x7bfff8f8ffffd9ffL & l) == 0L)
@ -276,7 +273,7 @@ private final int jjMoveNfa_3(int startState, int curPos)
{ {
if (kind > 18) if (kind > 18)
kind = 18; kind = 18;
jjCheckNAddStates(0, 4); jjCheckNAddStates(3, 7);
} }
else if (curChar == 92) else if (curChar == 92)
jjCheckNAddStates(13, 15); jjCheckNAddStates(13, 15);
@ -342,7 +339,7 @@ private final int jjMoveNfa_3(int startState, int curPos)
jjstateSet[jjnewStateCnt++] = 11; jjstateSet[jjnewStateCnt++] = 11;
break; break;
case 15: case 15:
jjAddStates(5, 7); jjAddStates(0, 2);
break; break;
case 17: case 17:
if (curChar == 92) if (curChar == 92)
@ -383,7 +380,7 @@ private final int jjMoveNfa_3(int startState, int curPos)
break; break;
if (kind > 18) if (kind > 18)
kind = 18; kind = 18;
jjCheckNAddStates(0, 4); jjCheckNAddStates(3, 7);
break; break;
case 29: case 29:
if ((0x97ffffff87ffffffL & l) == 0L) if ((0x97ffffff87ffffffL & l) == 0L)
@ -451,12 +448,12 @@ private final int jjMoveNfa_3(int startState, int curPos)
{ {
if (kind > 18) if (kind > 18)
kind = 18; kind = 18;
jjCheckNAddStates(0, 4); jjCheckNAddStates(3, 7);
} }
break; break;
case 15: case 15:
if (jjCanMove_0(hiByte, i1, i2, l1, l2)) if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjAddStates(5, 7); jjAddStates(0, 2);
break; break;
case 24: case 24:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
@ -470,7 +467,7 @@ private final int jjMoveNfa_3(int startState, int curPos)
break; break;
if (kind > 18) if (kind > 18)
kind = 18; kind = 18;
jjCheckNAddStates(0, 4); jjCheckNAddStates(3, 7);
break; break;
case 29: case 29:
case 31: case 31:
@ -955,7 +952,7 @@ private final int jjMoveNfa_2(int startState, int curPos)
} }
} }
static final int[] jjnextStates = { static final int[] jjnextStates = {
29, 32, 23, 33, 30, 15, 17, 18, 20, 21, 32, 23, 33, 31, 34, 27, 15, 17, 18, 29, 32, 23, 33, 30, 20, 21, 32, 23, 33, 31, 34, 27,
2, 4, 5, 0, 1, 2, 4, 5, 0, 1,
}; };
private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)

View File

@ -18,13 +18,8 @@ package org.apache.lucene.queryParser;
*/ */
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.LowerCaseTokenizer;
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.analysis.Token; import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.WhitespaceAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.DateField; import org.apache.lucene.document.DateField;
import org.apache.lucene.document.DateTools; import org.apache.lucene.document.DateTools;
@ -200,6 +195,9 @@ public class TestQueryParser extends TestCase {
assertQueryEquals("türm term term", new WhitespaceAnalyzer(), "türm term term"); assertQueryEquals("türm term term", new WhitespaceAnalyzer(), "türm term term");
assertQueryEquals("ümlaut", new WhitespaceAnalyzer(), "ümlaut"); assertQueryEquals("ümlaut", new WhitespaceAnalyzer(), "ümlaut");
assertQueryEquals("\"\"", new KeywordAnalyzer(), "");
assertQueryEquals("foo:\"\"", new KeywordAnalyzer(), "foo:");
assertQueryEquals("a AND b", null, "+a +b"); assertQueryEquals("a AND b", null, "+a +b");
assertQueryEquals("(a AND b)", null, "+a +b"); assertQueryEquals("(a AND b)", null, "+a +b");
assertQueryEquals("c OR (a AND b)", null, "c (+a +b)"); assertQueryEquals("c OR (a AND b)", null, "c (+a +b)");