Apache Lucene open-source search software
LUCENE-2566: QP unary operators +,-,! should not be followed by whitespace
Yonik Seeleydf1908187ebf
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 06237d99696..2b58f9480fd 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -152,6 +152,9 @@ API Changescall is the same as it was prior to the API change.(Grant Ingersoll, Mike McCandless)+* LUCENE-2566: QueryParser: Unary operators +,-,! will not be treated as+ operators if they are followed by whitespace. (yonik)+New features* LUCENE-2604: Added RegexpQuery support to QueryParser. Regular expressionsdiff --git a/lucene/src/java/org/apache/lucene/queryParser/QueryParser.java b/lucene/src/java/org/apache/lucene/queryParser/QueryParser.javaindex 46a86e7d2fc..d8b16103073 100644--- a/lucene/src/java/org/apache/lucene/queryParser/QueryParser.java+++ b/lucene/src/java/org/apache/lucene/queryParser/QueryParser.java@@ -219,6 +219,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstantscase NOT:case PLUS:case MINUS:+ case BAREOPER:case LPAREN:case STAR:case QUOTED:@@ -272,6 +273,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants;}switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {+ case BAREOPER:case STAR:case QUOTED:case TERM:@@ -316,6 +318,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstantsboolean endInc=false;Query q;switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {+ case BAREOPER:case STAR:case TERM:case PREFIXTERM:@@ -345,6 +348,10 @@ public class QueryParser extends QueryParserBase implements QueryParserConstantscase NUMBER:term = jj_consume_token(NUMBER);break;+ case BAREOPER:+ term = jj_consume_token(BAREOPER);+ term.image = term.image.substring(0,1);+ break;default:jj_la1[8] = jj_gen;jj_consume_token(-1);@@ -533,11 +540,16 @@ public class QueryParser extends QueryParserBase implements QueryParserConstantsprivate int jj_gen;final private int[] jj_la1 = new int[21];static private int[] jj_la1_0;+ static private int[] jj_la1_1;static {jj_la1_init_0();+ jj_la1_init_1();}private static void jj_la1_init_0() {- jj_la1_0 = new int[] {0x300,0x300,0x1c00,0x1c00,0x7ed3f00,0x90000,0x20000,0x7ed2000,0x4e90000,0x100000,0x100000,0x20000,0x3000000,0xc0000000,0x8000000,0xc0000000,0x30000000,0x20000,0x100000,0x20000,0x7ed0000,};+ jj_la1_0 = new int[] {0x300,0x300,0x1c00,0x1c00,0xfda7f00,0x120000,0x40000,0xfda6000,0x9d22000,0x200000,0x200000,0x40000,0x6000000,0x80000000,0x10000000,0x80000000,0x60000000,0x40000,0x200000,0x40000,0xfda2000,};+ }+ private static void jj_la1_init_1() {+ jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1,0x0,0x0,0x0,0x0,0x0,};}final private JJCalls[] jj_2_rtns = new JJCalls[1];private boolean jj_rescan = false;@@ -691,7 +703,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants/** Generate ParseException. */public ParseException generateParseException() {jj_expentries.clear();- boolean[] la1tokens = new boolean[32];+ boolean[] la1tokens = new boolean[33];if (jj_kind >= 0) {la1tokens[jj_kind] = true;jj_kind = -1;@@ -702,10 +714,13 @@ public class QueryParser extends QueryParserBase implements QueryParserConstantsif ((jj_la1_0[i] & (1<<j)) != 0) {la1tokens[j] = true;}+ if ((jj_la1_1[i] & (1<<j)) != 0) {+ la1tokens[32+j] = true;+ }}}}- for (int i = 0; i < 32; i++) {+ for (int i = 0; i < 33; i++) {if (la1tokens[i]) {jj_expentry = new int[1];jj_expentry[0] = i;diff --git a/lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj b/lucene/src/java/org/apache/lucene/queryParser/QueryParser.jjindex 600c52cb719..60568bbbf40 100644--- a/lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj+++ b/lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj@@ -183,6 +183,7 @@ PARSER_END(QueryParser)| <NOT: ("NOT" | "!") >| <PLUS: "+" >| <MINUS: "-" >+| <BAREOPER: ("+"|"-"|"!") <_WHITESPACE> >| <LPAREN: "(" >| <RPAREN: ")" >| <COLON: ":" >@@ -315,6 +316,7 @@ Query Term(String field) : {| term=<WILDTERM> { wildcard=true; }| term=<REGEXPTERM> { regexp=true; }| term=<NUMBER>+ | term=<BAREOPER> { term.image = term.image.substring(0,1); })[ fuzzySlop=<FUZZY_SLOP> { fuzzy=true; } ][ <CARAT> boost=<NUMBER> [ fuzzySlop=<FUZZY_SLOP> { fuzzy=true; } ] ]diff --git a/lucene/src/java/org/apache/lucene/queryParser/QueryParserConstants.java b/lucene/src/java/org/apache/lucene/queryParser/QueryParserConstants.javaindex df4ae5d63bd..9e9295eaef5 100644--- a/lucene/src/java/org/apache/lucene/queryParser/QueryParserConstants.java+++ b/lucene/src/java/org/apache/lucene/queryParser/QueryParserConstants.java@@ -33,43 +33,45 @@ public interface QueryParserConstants {/** RegularExpression Id. */int MINUS = 12;/** RegularExpression Id. */- int LPAREN = 13;+ int BAREOPER = 13;/** RegularExpression Id. */- int RPAREN = 14;+ int LPAREN = 14;/** RegularExpression Id. */- int COLON = 15;+ int RPAREN = 15;/** RegularExpression Id. */- int STAR = 16;+ int COLON = 16;/** RegularExpression Id. */- int CARAT = 17;+ int STAR = 17;/** RegularExpression Id. */- int QUOTED = 18;+ int CARAT = 18;/** RegularExpression Id. */- int TERM = 19;+ int QUOTED = 19;/** RegularExpression Id. */- int FUZZY_SLOP = 20;+ int TERM = 20;/** RegularExpression Id. */- int PREFIXTERM = 21;+ int FUZZY_SLOP = 21;/** RegularExpression Id. */- int WILDTERM = 22;+ int PREFIXTERM = 22;/** RegularExpression Id. */- int REGEXPTERM = 23;+ int WILDTERM = 23;/** RegularExpression Id. */- int RANGEIN_START = 24;+ int REGEXPTERM = 24;/** RegularExpression Id. */- int RANGEEX_START = 25;+ int RANGEIN_START = 25;/** RegularExpression Id. */- int NUMBER = 26;+ int RANGEEX_START = 26;/** RegularExpression Id. */- int RANGE_TO = 27;+ int NUMBER = 27;/** RegularExpression Id. */- int RANGEIN_END = 28;+ int RANGE_TO = 28;/** RegularExpression Id. */- int RANGEEX_END = 29;+ int RANGEIN_END = 29;/** RegularExpression Id. */- int RANGE_QUOTED = 30;+ int RANGEEX_END = 30;/** RegularExpression Id. */- int RANGE_GOOP = 31;+ int RANGE_QUOTED = 31;+ /** RegularExpression Id. */+ int RANGE_GOOP = 32;/** Lexical state. */int Boost = 0;@@ -93,6 +95,7 @@ public interface QueryParserConstants {"<NOT>","\"+\"","\"-\"",+ "<BAREOPER>","\"(\"","\")\"","\":\"",diff --git a/lucene/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java b/lucene/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.javaindex f0bb11d1c4f..7aa46a16a80 100644--- a/lucene/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java+++ b/lucene/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java@@ -67,23 +67,23 @@ private int jjMoveStringLiteralDfa0_2()switch(curChar){case 40:- return jjStopAtPos(0, 13);- case 41:return jjStopAtPos(0, 14);+ case 41:+ return jjStopAtPos(0, 15);case 42:- return jjStartNfaWithStates_2(0, 16, 41);+ return jjStartNfaWithStates_2(0, 17, 43);case 43:- return jjStopAtPos(0, 11);+ return jjStartNfaWithStates_2(0, 11, 15);case 45:- return jjStopAtPos(0, 12);+ return jjStartNfaWithStates_2(0, 12, 15);case 58:- return jjStopAtPos(0, 15);+ return jjStopAtPos(0, 16);case 91:- return jjStopAtPos(0, 24);+ return jjStopAtPos(0, 25);case 94:- return jjStopAtPos(0, 17);+ return jjStopAtPos(0, 18);case 123:- return jjStopAtPos(0, 25);+ return jjStopAtPos(0, 26);default :return jjMoveNfa_2(0, 0);}@@ -111,7 +111,7 @@ static final long[] jjbitVec4 = {private int jjMoveNfa_2(int startState, int curPos){int startsAt = 0;- jjnewStateCnt = 41;+ jjnewStateCnt = 43;int i = 1;jjstateSet[0] = startState;int kind = 0x7fffffff;@@ -129,45 +129,47 @@ private int jjMoveNfa_2(int startState, int curPos)case 0:if ((0xfbffd4f8ffffd9ffL & l) != 0L){- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);}else if ((0x100002600L & l) != 0L){if (kind > 7)kind = 7;}+ else if ((0x280200000000L & l) != 0L)+ jjstateSet[jjnewStateCnt++] = 15;else if (curChar == 34)jjCheckNAddStates(0, 2);- else if (curChar == 33)- {- if (kind > 10)- kind = 10;- }if ((0x7bffd0f8ffffd9ffL & l) != 0L){- if (kind > 19)- kind = 19;+ if (kind > 20)+ kind = 20;jjCheckNAddStates(3, 7);}else if (curChar == 42){- if (kind > 21)- kind = 21;+ if (kind > 22)+ kind = 22;+ }+ else if (curChar == 33)+ {+ if (kind > 10)+ kind = 10;}if (curChar == 47)jjCheckNAddStates(8, 10);else if (curChar == 38)jjstateSet[jjnewStateCnt++] = 4;break;- case 41:- case 25:+ case 43:+ case 27:if ((0xfbfffcf8ffffd9ffL & l) == 0L)break;- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);break;case 4:if (curChar == 38 && kind > 8)@@ -182,91 +184,99 @@ private int jjMoveNfa_2(int startState, int curPos)kind = 10;break;case 14:+ if ((0x280200000000L & l) != 0L)+ jjstateSet[jjnewStateCnt++] = 15;+ break;+ case 15:+ if ((0x100002600L & l) != 0L && kind > 13)+ kind = 13;+ break;+ case 16:if (curChar == 34)jjCheckNAddStates(0, 2);break;- case 15:+ case 17:if ((0xfffffffbffffffffL & l) != 0L)jjCheckNAddStates(0, 2);break;- case 17:+ case 19:jjCheckNAddStates(0, 2);break;- case 18:- if (curChar == 34 && kind > 18)- kind = 18;- break;case 20:+ if (curChar == 34 && kind > 19)+ kind = 19;+ break;+ case 22:if ((0x3ff000000000000L & l) == 0L)break;- if (kind > 20)- kind = 20;+ if (kind > 21)+ kind = 21;jjAddStates(11, 12);break;- case 21:+ case 23:if (curChar == 46)- jjCheckNAdd(22);+ jjCheckNAdd(24);break;- case 22:+ case 24:if ((0x3ff000000000000L & l) == 0L)break;- if (kind > 20)- kind = 20;- jjCheckNAdd(22);- break;- case 23:- if (curChar == 42 && kind > 21)+ if (kind > 21)kind = 21;+ jjCheckNAdd(24);break;- case 24:+ case 25:+ if (curChar == 42 && kind > 22)+ kind = 22;+ break;+ case 26:if ((0xfbffd4f8ffffd9ffL & l) == 0L)break;- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);break;- case 27:- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ case 29:+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);break;- case 28:case 30:+ case 32:if (curChar == 47)jjCheckNAddStates(8, 10);break;- case 29:+ case 31:if ((0xffff7fffffffffffL & l) != 0L)jjCheckNAddStates(8, 10);break;- case 32:- if (curChar == 47 && kind > 23)- kind = 23;+ case 34:+ if (curChar == 47 && kind > 24)+ kind = 24;break;- case 33:+ case 35:if ((0x7bffd0f8ffffd9ffL & l) == 0L)break;- if (kind > 19)- kind = 19;+ if (kind > 20)+ kind = 20;jjCheckNAddStates(3, 7);break;- case 34:+ case 36:if ((0x7bfff8f8ffffd9ffL & l) == 0L)break;- if (kind > 19)- kind = 19;- jjCheckNAddTwoStates(34, 35);+ if (kind > 20)+ kind = 20;+ jjCheckNAddTwoStates(36, 37);break;- case 36:- if (kind > 19)- kind = 19;- jjCheckNAddTwoStates(34, 35);+ case 38:+ if (kind > 20)+ kind = 20;+ jjCheckNAddTwoStates(36, 37);break;- case 37:+ case 39:if ((0x7bfff8f8ffffd9ffL & l) != 0L)jjCheckNAddStates(13, 15);break;- case 39:+ case 41:jjCheckNAddStates(13, 15);break;default : break;@@ -283,23 +293,23 @@ private int jjMoveNfa_2(int startState, int curPos)case 0:if ((0x97ffffff87ffffffL & l) != 0L){- if (kind > 19)- kind = 19;+ if (kind > 20)+ kind = 20;jjCheckNAddStates(3, 7);}else if (curChar == 92)jjCheckNAddStates(16, 18);else if (curChar == 126){- if (kind > 20)- kind = 20;- jjstateSet[jjnewStateCnt++] = 20;+ if (kind > 21)+ kind = 21;+ jjstateSet[jjnewStateCnt++] = 22;}if ((0x97ffffff87ffffffL & l) != 0L){- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);}if (curChar == 78)jjstateSet[jjnewStateCnt++] = 11;@@ -310,15 +320,15 @@ private int jjMoveNfa_2(int startState, int curPos)else if (curChar == 65)jjstateSet[jjnewStateCnt++] = 2;break;- case 41:+ case 43:if ((0x97ffffff87ffffffL & l) != 0L){- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);}else if (curChar == 92)- jjCheckNAddTwoStates(27, 27);+ jjCheckNAddTwoStates(29, 29);break;case 1:if (curChar == 68 && kind > 8)@@ -360,89 +370,89 @@ private int jjMoveNfa_2(int startState, int curPos)if (curChar == 78)jjstateSet[jjnewStateCnt++] = 11;break;- case 15:+ case 17:if ((0xffffffffefffffffL & l) != 0L)jjCheckNAddStates(0, 2);break;- case 16:+ case 18:if (curChar == 92)- jjstateSet[jjnewStateCnt++] = 17;+ jjstateSet[jjnewStateCnt++] = 19;break;- case 17:+ case 19:jjCheckNAddStates(0, 2);break;- case 19:+ case 21:if (curChar != 126)break;- if (kind > 20)- kind = 20;- jjstateSet[jjnewStateCnt++] = 20;+ if (kind > 21)+ kind = 21;+ jjstateSet[jjnewStateCnt++] = 22;break;- case 24:+ case 26:if ((0x97ffffff87ffffffL & l) == 0L)break;- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);break;- case 25:+ case 27:if ((0x97ffffff87ffffffL & l) == 0L)break;- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);break;- case 26:+ case 28:if (curChar == 92)- jjCheckNAddTwoStates(27, 27);- break;- case 27:- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ jjCheckNAddTwoStates(29, 29);break;case 29:- jjAddStates(8, 10);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);break;case 31:- if (curChar == 92)- jjstateSet[jjnewStateCnt++] = 30;+ jjAddStates(8, 10);break;case 33:+ if (curChar == 92)+ jjstateSet[jjnewStateCnt++] = 32;+ break;+ case 35:if ((0x97ffffff87ffffffL & l) == 0L)break;- if (kind > 19)- kind = 19;+ if (kind > 20)+ kind = 20;jjCheckNAddStates(3, 7);break;- case 34:+ case 36:if ((0x97ffffff87ffffffL & l) == 0L)break;- if (kind > 19)- kind = 19;- jjCheckNAddTwoStates(34, 35);+ if (kind > 20)+ kind = 20;+ jjCheckNAddTwoStates(36, 37);break;- case 35:+ case 37:if (curChar == 92)- jjCheckNAddTwoStates(36, 36);+ jjCheckNAddTwoStates(38, 38);break;- case 36:- if (kind > 19)- kind = 19;- jjCheckNAddTwoStates(34, 35);+ case 38:+ if (kind > 20)+ kind = 20;+ jjCheckNAddTwoStates(36, 37);break;- case 37:+ case 39:if ((0x97ffffff87ffffffL & l) != 0L)jjCheckNAddStates(13, 15);break;- case 38:+ case 40:if (curChar == 92)- jjCheckNAddTwoStates(39, 39);+ jjCheckNAddTwoStates(41, 41);break;- case 39:+ case 41:jjCheckNAddStates(13, 15);break;- case 40:+ case 42:if (curChar == 92)jjCheckNAddStates(16, 18);break;@@ -469,74 +479,78 @@ private int jjMoveNfa_2(int startState, int curPos)}if (jjCanMove_2(hiByte, i1, i2, l1, l2)){- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);}if (jjCanMove_2(hiByte, i1, i2, l1, l2)){- if (kind > 19)- kind = 19;+ if (kind > 20)+ kind = 20;jjCheckNAddStates(3, 7);}break;- case 41:- case 25:+ case 43:+ case 27:if (!jjCanMove_2(hiByte, i1, i2, l1, l2))break;- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);break;case 15:+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 13)+ kind = 13;+ break;case 17:+ case 19:if (jjCanMove_1(hiByte, i1, i2, l1, l2))jjCheckNAddStates(0, 2);break;- case 24:+ case 26:if (!jjCanMove_2(hiByte, i1, i2, l1, l2))break;- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);break;- case 27:+ case 29:if (!jjCanMove_1(hiByte, i1, i2, l1, l2))break;- if (kind > 22)- kind = 22;- jjCheckNAddTwoStates(25, 26);+ if (kind > 23)+ kind = 23;+ jjCheckNAddTwoStates(27, 28);break;- case 29:+ case 31:if (jjCanMove_1(hiByte, i1, i2, l1, l2))jjAddStates(8, 10);break;- case 33:+ case 35:if (!jjCanMove_2(hiByte, i1, i2, l1, l2))break;- if (kind > 19)- kind = 19;+ if (kind > 20)+ kind = 20;jjCheckNAddStates(3, 7);break;- case 34:+ case 36:if (!jjCanMove_2(hiByte, i1, i2, l1, l2))break;- if (kind > 19)- kind = 19;- jjCheckNAddTwoStates(34, 35);+ if (kind > 20)+ kind = 20;+ jjCheckNAddTwoStates(36, 37);break;- case 36:+ case 38:if (!jjCanMove_1(hiByte, i1, i2, l1, l2))break;- if (kind > 19)- kind = 19;- jjCheckNAddTwoStates(34, 35);+ if (kind > 20)+ kind = 20;+ jjCheckNAddTwoStates(36, 37);break;- case 37:+ case 39:if (jjCanMove_2(hiByte, i1, i2, l1, l2))jjCheckNAddStates(13, 15);break;- case 39:+ case 41:if (jjCanMove_1(hiByte, i1, i2, l1, l2))jjCheckNAddStates(13, 15);break;@@ -551,7 +565,7 @@ private int jjMoveNfa_2(int startState, int curPos)kind = 0x7fffffff;}++curPos;- if ((i = jjnewStateCnt) == (startsAt = 41 - (jjnewStateCnt = startsAt)))+ if ((i = jjnewStateCnt) == (startsAt = 43 - (jjnewStateCnt = startsAt)))return curPos;try { curChar = input_stream.readChar(); }catch(java.io.IOException e) { return curPos; }@@ -582,8 +596,8 @@ private int jjMoveNfa_0(int startState, int curPos)case 0:if ((0x3ff000000000000L & l) == 0L)break;- if (kind > 26)- kind = 26;+ if (kind > 27)+ kind = 27;jjAddStates(19, 20);break;case 1:@@ -593,8 +607,8 @@ private int jjMoveNfa_0(int startState, int curPos)case 2:if ((0x3ff000000000000L & l) == 0L)break;- if (kind > 26)- kind = 26;+ if (kind > 27)+ kind = 27;jjCheckNAdd(2);break;default : break;@@ -645,9 +659,9 @@ private final int jjStopStringLiteralDfa_1(int pos, long active0)switch (pos){case 0:- if ((active0 & 0x8000000L) != 0L)+ if ((active0 & 0x10000000L) != 0L){- jjmatchedKind = 31;+ jjmatchedKind = 32;return 6;}return -1;@@ -664,11 +678,11 @@ private int jjMoveStringLiteralDfa0_1()switch(curChar){case 84:- return jjMoveStringLiteralDfa1_1(0x8000000L);+ return jjMoveStringLiteralDfa1_1(0x10000000L);case 93:- return jjStopAtPos(0, 28);- case 125:return jjStopAtPos(0, 29);+ case 125:+ return jjStopAtPos(0, 30);default :return jjMoveNfa_1(0, 0);}@@ -683,8 +697,8 @@ private int jjMoveStringLiteralDfa1_1(long active0)switch(curChar){case 79:- if ((active0 & 0x8000000L) != 0L)- return jjStartNfaWithStates_1(1, 27, 6);+ if ((active0 & 0x10000000L) != 0L)+ return jjStartNfaWithStates_1(1, 28, 6);break;default :break;@@ -720,8 +734,8 @@ private int jjMoveNfa_1(int startState, int curPos)case 0:if ((0xfffffffeffffffffL & l) != 0L){- if (kind > 31)- kind = 31;+ if (kind > 32)+ kind = 32;jjCheckNAdd(6);}if ((0x100002600L & l) != 0L)@@ -745,14 +759,14 @@ private int jjMoveNfa_1(int startState, int curPos)jjCheckNAddStates(21, 23);break;case 5:- if (curChar == 34 && kind > 30)- kind = 30;+ if (curChar == 34 && kind > 31)+ kind = 31;break;case 6:if ((0xfffffffeffffffffL & l) == 0L)break;- if (kind > 31)- kind = 31;+ if (kind > 32)+ kind = 32;jjCheckNAdd(6);break;default : break;@@ -770,8 +784,8 @@ private int jjMoveNfa_1(int startState, int curPos)case 6:if ((0xdfffffffdfffffffL & l) == 0L)break;- if (kind > 31)- kind = 31;+ if (kind > 32)+ kind = 32;jjCheckNAdd(6);break;case 2:@@ -804,8 +818,8 @@ private int jjMoveNfa_1(int startState, int curPos)}if (jjCanMove_1(hiByte, i1, i2, l1, l2)){- if (kind > 31)- kind = 31;+ if (kind > 32)+ kind = 32;jjCheckNAdd(6);}break;@@ -816,8 +830,8 @@ private int jjMoveNfa_1(int startState, int curPos)case 6:if (!jjCanMove_1(hiByte, i1, i2, l1, l2))break;- if (kind > 31)- kind = 31;+ if (kind > 32)+ kind = 32;jjCheckNAdd(6);break;default : break;@@ -838,8 +852,8 @@ private int jjMoveNfa_1(int startState, int curPos)}}static final int[] jjnextStates = {- 15, 16, 18, 34, 37, 23, 38, 35, 29, 31, 32, 20, 21, 37, 23, 38,- 36, 39, 27, 0, 1, 2, 4, 5,+ 17, 18, 20, 36, 39, 25, 40, 37, 31, 33, 34, 22, 23, 39, 25, 40,+ 38, 41, 29, 0, 1, 2, 4, 5,};private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2){@@ -881,8 +895,8 @@ private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, lo/** Token literal values. */public static final String[] jjstrLiteralImages = {"", null, null, null, null, null, null, null, null, null, null, "\53", "\55",-"\50", "\51", "\72", "\52", "\136", null, null, null, null, null, null, "\133",-"\173", null, "\124\117", "\135", "\175", null, null, };+null, "\50", "\51", "\72", "\52", "\136", null, null, null, null, null, null,+"\133", "\173", null, "\124\117", "\135", "\175", null, null, };/** Lexer state names. */public static final String[] lexStateNames = {@@ -893,18 +907,18 @@ public static final String[] lexStateNames = {/** Lex State array. */public static final int[] jjnewLexState = {- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, 1,- 1, 2, -1, 2, 2, -1, -1,+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1,+ 1, 1, 2, -1, 2, 2, -1, -1,};static final long[] jjtoToken = {- 0xffffff01L,+ 0x1ffffff01L,};static final long[] jjtoSkip = {0x80L,};protected CharStream input_stream;-private final int[] jjrounds = new int[41];-private final int[] jjstateSet = new int[82];+private final int[] jjrounds = new int[43];+private final int[] jjstateSet = new int[86];protected char curChar;/** Constructor. */public QueryParserTokenManager(CharStream stream){@@ -929,7 +943,7 @@ private void ReInitRounds(){int i;jjround = 0x80000001;- for (i = 41; i-- > 0;)+ for (i = 43; i-- > 0;)jjrounds[i] = 0x80000000;}diff --git a/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java b/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.javaindex 6f6a4fdd0fd..2d9cd0541ec 100644--- a/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java+++ b/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java@@ -353,14 +353,25 @@ public class TestQueryParser extends LuceneTestCase {assertQueryEquals("a AND -b", null, "+a -b");assertQueryEquals("a AND !b", null, "+a -b");assertQueryEquals("a && b", null, "+a +b");- assertQueryEquals("a && ! b", null, "+a -b");+// assertQueryEquals("a && ! b", null, "+a -b");assertQueryEquals("a OR b", null, "a b");assertQueryEquals("a || b", null, "a b");assertQueryEquals("a OR !b", null, "a -b");- assertQueryEquals("a OR ! b", null, "a -b");+// assertQueryEquals("a OR ! b", null, "a -b");assertQueryEquals("a OR -b", null, "a -b");+ // +,-,! should be directly adjacent to operand (i.e. not separated by whitespace) to be treated as an operator+ Analyzer a = new Analyzer() {+ @Override+ public TokenStream tokenStream(String fieldName, Reader reader) {+ return new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);+ }+ };+ assertQueryEquals("a - b", a, "a - b");+ assertQueryEquals("a + b", a, "a + b");+ assertQueryEquals("a ! b", a, "a ! b");+assertQueryEquals("+term -term term", null, "+term -term term");assertQueryEquals("foo:term AND field:anotherTerm", null,"+foo:term +anotherterm");