You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by yo...@apache.org on 2006/11/28 19:29:29 UTC
svn commit: r480150 - in /lucene/java/trunk: ./
src/java/org/apache/lucene/queryParser/
src/test/org/apache/lucene/queryParser/
Author: yonik
Date: Tue Nov 28 10:29:28 2006
New Revision: 480150
URL: http://svn.apache.org/viewvc?view=rev&rev=480150
Log:
map *:* to MatchAllDocsQuery: LUCENE-723
Modified:
lucene/java/trunk/CHANGES.txt
lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.java
lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.jj
lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParserConstants.java
lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java
lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java
Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=480150&r1=480149&r2=480150
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Tue Nov 28 10:29:28 2006
@@ -77,6 +77,8 @@
control the amount of memory used to buffer documents.
(Chuck Williams via Yonik Seeley)
+10. LUCENE-723: QueryParser now parses *:* as MatchAllDocsQuery
+ (Yonik Seeley)
API Changes
Modified: lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.java?view=diff&rev=480150&r1=480149&r2=480150
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.java Tue Nov 28 10:29:28 2006
@@ -553,6 +553,9 @@
*/
protected Query getWildcardQuery(String field, String termStr) throws ParseException
{
+ if ("*".equals(field)) {
+ if ("*".equals(termStr)) return new MatchAllDocsQuery();
+ }
if (!allowLeadingWildcard && (termStr.startsWith("*") || termStr.startsWith("?")))
throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery");
if (lowercaseExpandedTerms) {
@@ -814,6 +817,7 @@
case PLUS:
case MINUS:
case LPAREN:
+ case STAR:
case QUOTED:
case TERM:
case PREFIXTERM:
@@ -844,13 +848,27 @@
Query q;
Token fieldToken=null, boost=null;
if (jj_2_1(2)) {
- fieldToken = jj_consume_token(TERM);
- jj_consume_token(COLON);
- field=discardEscapeChar(fieldToken.image);
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case TERM:
+ fieldToken = jj_consume_token(TERM);
+ jj_consume_token(COLON);
+ field=discardEscapeChar(fieldToken.image);
+ break;
+ case STAR:
+ jj_consume_token(STAR);
+ jj_consume_token(COLON);
+ field="*";
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
} else {
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case STAR:
case QUOTED:
case TERM:
case PREFIXTERM:
@@ -870,12 +888,12 @@
boost = jj_consume_token(NUMBER);
break;
default:
- jj_la1[5] = jj_gen;
+ jj_la1[6] = jj_gen;
;
}
break;
default:
- jj_la1[6] = jj_gen;
+ jj_la1[7] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -898,6 +916,7 @@
boolean rangein = false;
Query q;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case STAR:
case TERM:
case PREFIXTERM:
case WILDTERM:
@@ -906,6 +925,10 @@
case TERM:
term = jj_consume_token(TERM);
break;
+ case STAR:
+ term = jj_consume_token(STAR);
+ wildcard=true;
+ break;
case PREFIXTERM:
term = jj_consume_token(PREFIXTERM);
prefix=true;
@@ -918,7 +941,7 @@
term = jj_consume_token(NUMBER);
break;
default:
- jj_la1[7] = jj_gen;
+ jj_la1[8] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -928,7 +951,7 @@
fuzzy=true;
break;
default:
- jj_la1[8] = jj_gen;
+ jj_la1[9] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -941,12 +964,12 @@
fuzzy=true;
break;
default:
- jj_la1[9] = jj_gen;
+ jj_la1[10] = jj_gen;
;
}
break;
default:
- jj_la1[10] = jj_gen;
+ jj_la1[11] = jj_gen;
;
}
String termImage=discardEscapeChar(term.image);
@@ -979,7 +1002,7 @@
goop1 = jj_consume_token(RANGEIN_QUOTED);
break;
default:
- jj_la1[11] = jj_gen;
+ jj_la1[12] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -988,7 +1011,7 @@
jj_consume_token(RANGEIN_TO);
break;
default:
- jj_la1[12] = jj_gen;
+ jj_la1[13] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -999,7 +1022,7 @@
goop2 = jj_consume_token(RANGEIN_QUOTED);
break;
default:
- jj_la1[13] = jj_gen;
+ jj_la1[14] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -1010,7 +1033,7 @@
boost = jj_consume_token(NUMBER);
break;
default:
- jj_la1[14] = jj_gen;
+ jj_la1[15] = jj_gen;
;
}
if (goop1.kind == RANGEIN_QUOTED) {
@@ -1031,7 +1054,7 @@
goop1 = jj_consume_token(RANGEEX_QUOTED);
break;
default:
- jj_la1[15] = jj_gen;
+ jj_la1[16] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -1040,7 +1063,7 @@
jj_consume_token(RANGEEX_TO);
break;
default:
- jj_la1[16] = jj_gen;
+ jj_la1[17] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -1051,7 +1074,7 @@
goop2 = jj_consume_token(RANGEEX_QUOTED);
break;
default:
- jj_la1[17] = jj_gen;
+ jj_la1[18] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -1062,7 +1085,7 @@
boost = jj_consume_token(NUMBER);
break;
default:
- jj_la1[18] = jj_gen;
+ jj_la1[19] = jj_gen;
;
}
if (goop1.kind == RANGEEX_QUOTED) {
@@ -1081,7 +1104,7 @@
fuzzySlop = jj_consume_token(FUZZY_SLOP);
break;
default:
- jj_la1[19] = jj_gen;
+ jj_la1[20] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -1090,7 +1113,7 @@
boost = jj_consume_token(NUMBER);
break;
default:
- jj_la1[20] = jj_gen;
+ jj_la1[21] = jj_gen;
;
}
int s = phraseSlop;
@@ -1104,7 +1127,7 @@
q = getFieldQuery(field, discardEscapeChar(term.image.substring(1, term.image.length()-1)), s);
break;
default:
- jj_la1[21] = jj_gen;
+ jj_la1[22] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -1135,12 +1158,28 @@
finally { jj_save(0, xla); }
}
- final private boolean jj_3_1() {
+ final private boolean jj_3R_2() {
if (jj_scan_token(TERM)) return true;
if (jj_scan_token(COLON)) return true;
return false;
}
+ final private boolean jj_3_1() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_2()) {
+ jj_scanpos = xsp;
+ if (jj_3R_3()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_3() {
+ if (jj_scan_token(STAR)) return true;
+ if (jj_scan_token(COLON)) return true;
+ return false;
+ }
+
public QueryParserTokenManager token_source;
public Token token, jj_nt;
private int jj_ntk;
@@ -1149,13 +1188,18 @@
public boolean lookingAhead = false;
private boolean jj_semLA;
private int jj_gen;
- final private int[] jj_la1 = new int[22];
+ final private int[] jj_la1 = new int[23];
static private int[] jj_la1_0;
+ static private int[] jj_la1_1;
static {
jj_la1_0();
+ jj_la1_1();
}
private static void jj_la1_0() {
- jj_la1_0 = new int[] {0x180,0x180,0xe00,0xe00,0xfb1f80,0x8000,0xfb1000,0x9a0000,0x40000,0x40000,0x8000,0xc000000,0x1000000,0xc000000,0x8000,0xc0000000,0x10000000,0xc0000000,0x8000,0x40000,0x8000,0xfb0000,};
+ jj_la1_0 = new int[] {0x180,0x180,0xe00,0xe00,0x1f69f80,0x48000,0x10000,0x1f69000,0x1348000,0x80000,0x80000,0x10000,0x18000000,0x2000000,0x18000000,0x10000,0x80000000,0x20000000,0x80000000,0x10000,0x80000,0x10000,0x1f68000,};
+ }
+ private static void jj_la1_1() {
+ jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1,0x0,0x0,0x0,0x0,};
}
final private JJCalls[] jj_2_rtns = new JJCalls[1];
private boolean jj_rescan = false;
@@ -1166,7 +1210,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 22; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 23; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1175,7 +1219,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 22; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 23; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1184,7 +1228,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 22; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 23; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1193,7 +1237,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 22; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 23; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1304,24 +1348,27 @@
public ParseException generateParseException() {
jj_expentries.removeAllElements();
- boolean[] la1tokens = new boolean[32];
- for (int i = 0; i < 32; i++) {
+ boolean[] la1tokens = new boolean[33];
+ for (int i = 0; i < 33; i++) {
la1tokens[i] = false;
}
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
- for (int i = 0; i < 22; i++) {
+ for (int i = 0; i < 23; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((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;
Modified: lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.jj
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.jj?view=diff&rev=480150&r1=480149&r2=480150
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.jj (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParser.jj Tue Nov 28 10:29:28 2006
@@ -577,6 +577,9 @@
*/
protected Query getWildcardQuery(String field, String termStr) throws ParseException
{
+ if ("*".equals(field)) {
+ if ("*".equals(termStr)) return new MatchAllDocsQuery();
+ }
if (!allowLeadingWildcard && (termStr.startsWith("*") || termStr.startsWith("?")))
throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery");
if (lowercaseExpandedTerms) {
@@ -789,6 +792,7 @@
| <LPAREN: "(" >
| <RPAREN: ")" >
| <COLON: ":" >
+| <STAR: "*" >
| <CARAT: "^" > : Boost
| <QUOTED: "\"" (~["\""] | "\\\"")+ "\"">
| <TERM: <_TERM_START_CHAR> (<_TERM_CHAR>)* >
@@ -876,9 +880,10 @@
{
[
LOOKAHEAD(2)
- fieldToken=<TERM> <COLON> {
- field=discardEscapeChar(fieldToken.image);
- }
+ (
+ fieldToken=<TERM> <COLON> {field=discardEscapeChar(fieldToken.image);}
+ | <STAR> <COLON> {field="*";}
+ )
]
(
@@ -911,6 +916,7 @@
(
(
term=<TERM>
+ | term=<STAR> { wildcard=true; }
| term=<PREFIXTERM> { prefix=true; }
| term=<WILDTERM> { wildcard=true; }
| term=<NUMBER>
Modified: lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParserConstants.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParserConstants.java?view=diff&rev=480150&r1=480149&r2=480150
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParserConstants.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParserConstants.java Tue Nov 28 10:29:28 2006
@@ -17,23 +17,24 @@
int LPAREN = 12;
int RPAREN = 13;
int COLON = 14;
- int CARAT = 15;
- int QUOTED = 16;
- int TERM = 17;
- int FUZZY_SLOP = 18;
- int PREFIXTERM = 19;
- int WILDTERM = 20;
- int RANGEIN_START = 21;
- int RANGEEX_START = 22;
- int NUMBER = 23;
- int RANGEIN_TO = 24;
- int RANGEIN_END = 25;
- int RANGEIN_QUOTED = 26;
- int RANGEIN_GOOP = 27;
- int RANGEEX_TO = 28;
- int RANGEEX_END = 29;
- int RANGEEX_QUOTED = 30;
- int RANGEEX_GOOP = 31;
+ int STAR = 15;
+ int CARAT = 16;
+ int QUOTED = 17;
+ int TERM = 18;
+ int FUZZY_SLOP = 19;
+ int PREFIXTERM = 20;
+ int WILDTERM = 21;
+ int RANGEIN_START = 22;
+ int RANGEEX_START = 23;
+ int NUMBER = 24;
+ int RANGEIN_TO = 25;
+ int RANGEIN_END = 26;
+ int RANGEIN_QUOTED = 27;
+ int RANGEIN_GOOP = 28;
+ int RANGEEX_TO = 29;
+ int RANGEEX_END = 30;
+ int RANGEEX_QUOTED = 31;
+ int RANGEEX_GOOP = 32;
int Boost = 0;
int RangeEx = 1;
@@ -56,6 +57,7 @@
"\"(\"",
"\")\"",
"\":\"",
+ "\"*\"",
"\"^\"",
"<QUOTED>",
"<TERM>",
Modified: lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java?view=diff&rev=480150&r1=480149&r2=480150
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java Tue Nov 28 10:29:28 2006
@@ -48,6 +48,8 @@
return jjStopAtPos(0, 12);
case 41:
return jjStopAtPos(0, 13);
+ case 42:
+ return jjStartNfaWithStates_3(0, 15, 37);
case 43:
return jjStopAtPos(0, 10);
case 45:
@@ -55,11 +57,11 @@
case 58:
return jjStopAtPos(0, 14);
case 91:
- return jjStopAtPos(0, 21);
+ return jjStopAtPos(0, 22);
case 94:
- return jjStopAtPos(0, 15);
+ return jjStopAtPos(0, 16);
case 123:
- return jjStopAtPos(0, 22);
+ return jjStopAtPos(0, 23);
default :
return jjMoveNfa_3(0, 0);
}
@@ -119,11 +121,26 @@
{
switch(jjstateSet[--i])
{
- case 0:
- if ((0xfbffd4f8ffffd9ffL & l) != 0L)
+ case 37:
+ if ((0xfbfffcf8ffffd9ffL & l) != 0L)
+ {
+ if (kind > 21)
+ kind = 21;
+ jjCheckNAddTwoStates(33, 34);
+ }
+ if ((0x7bfff8f8ffffd9ffL & l) != 0L)
+ jjCheckNAddStates(0, 2);
+ else if (curChar == 42)
{
if (kind > 20)
kind = 20;
+ }
+ break;
+ case 0:
+ if ((0xfbffd4f8ffffd9ffL & l) != 0L)
+ {
+ if (kind > 21)
+ kind = 21;
jjCheckNAddTwoStates(33, 34);
}
else if ((0x100002600L & l) != 0L)
@@ -142,8 +159,8 @@
jjCheckNAddStates(0, 2);
if ((0x7bffd0f8ffffd9ffL & l) != 0L)
{
- if (kind > 17)
- kind = 17;
+ if (kind > 18)
+ kind = 18;
jjCheckNAddTwoStates(20, 21);
}
if (curChar == 38)
@@ -174,35 +191,35 @@
jjCheckNAddStates(3, 5);
break;
case 18:
- if (curChar == 34 && kind > 16)
- kind = 16;
+ if (curChar == 34 && kind > 17)
+ kind = 17;
break;
case 19:
if ((0x7bffd0f8ffffd9ffL & l) == 0L)
break;
- if (kind > 17)
- kind = 17;
+ if (kind > 18)
+ kind = 18;
jjCheckNAddTwoStates(20, 21);
break;
case 20:
if ((0x7bfff8f8ffffd9ffL & l) == 0L)
break;
- if (kind > 17)
- kind = 17;
+ if (kind > 18)
+ kind = 18;
jjCheckNAddTwoStates(20, 21);
break;
case 22:
if ((0x84002f0600000000L & l) == 0L)
break;
- if (kind > 17)
- kind = 17;
+ if (kind > 18)
+ kind = 18;
jjCheckNAddTwoStates(20, 21);
break;
case 24:
if ((0x3ff000000000000L & l) == 0L)
break;
- if (kind > 18)
- kind = 18;
+ if (kind > 19)
+ kind = 19;
jjAddStates(6, 7);
break;
case 25:
@@ -212,8 +229,8 @@
case 26:
if ((0x3ff000000000000L & l) == 0L)
break;
- if (kind > 18)
- kind = 18;
+ if (kind > 19)
+ kind = 19;
jjCheckNAdd(26);
break;
case 27:
@@ -225,8 +242,8 @@
jjCheckNAddStates(0, 2);
break;
case 29:
- if (curChar == 42 && kind > 19)
- kind = 19;
+ if (curChar == 42 && kind > 20)
+ kind = 20;
break;
case 31:
if ((0x84002f0600000000L & l) != 0L)
@@ -235,22 +252,22 @@
case 32:
if ((0xfbffd4f8ffffd9ffL & l) == 0L)
break;
- if (kind > 20)
- kind = 20;
+ if (kind > 21)
+ kind = 21;
jjCheckNAddTwoStates(33, 34);
break;
case 33:
if ((0xfbfffcf8ffffd9ffL & l) == 0L)
break;
- if (kind > 20)
- kind = 20;
+ if (kind > 21)
+ kind = 21;
jjCheckNAddTwoStates(33, 34);
break;
case 35:
if ((0x84002f0600000000L & l) == 0L)
break;
- if (kind > 20)
- kind = 20;
+ if (kind > 21)
+ kind = 21;
jjCheckNAddTwoStates(33, 34);
break;
default : break;
@@ -264,25 +281,39 @@
{
switch(jjstateSet[--i])
{
+ case 37:
+ if ((0x97ffffff97ffffffL & l) != 0L)
+ {
+ if (kind > 21)
+ kind = 21;
+ jjCheckNAddTwoStates(33, 34);
+ }
+ if ((0x97ffffff97ffffffL & l) != 0L)
+ jjCheckNAddStates(0, 2);
+ if (curChar == 92)
+ jjCheckNAddTwoStates(31, 31);
+ if (curChar == 92)
+ jjCheckNAddTwoStates(35, 35);
+ break;
case 0:
if ((0x97ffffff97ffffffL & l) != 0L)
{
- if (kind > 20)
- kind = 20;
+ if (kind > 21)
+ kind = 21;
jjCheckNAddTwoStates(33, 34);
}
else if (curChar == 126)
{
- if (kind > 18)
- kind = 18;
+ if (kind > 19)
+ kind = 19;
jjstateSet[jjnewStateCnt++] = 24;
}
if ((0x97ffffff97ffffffL & l) != 0L)
jjCheckNAddStates(0, 2);
if ((0x97ffffff97ffffffL & l) != 0L)
{
- if (kind > 17)
- kind = 17;
+ if (kind > 18)
+ kind = 18;
jjCheckNAddTwoStates(20, 21);
}
if (curChar == 92)
@@ -347,8 +378,8 @@
case 20:
if ((0x97ffffff97ffffffL & l) == 0L)
break;
- if (kind > 17)
- kind = 17;
+ if (kind > 18)
+ kind = 18;
jjCheckNAddTwoStates(20, 21);
break;
case 21:
@@ -358,18 +389,21 @@
case 22:
if ((0x6800000078000000L & l) == 0L)
break;
- if (kind > 17)
- kind = 17;
+ if (kind > 18)
+ kind = 18;
jjCheckNAddTwoStates(20, 21);
break;
case 23:
if (curChar != 126)
break;
- if (kind > 18)
- kind = 18;
+ if (kind > 19)
+ kind = 19;
jjstateSet[jjnewStateCnt++] = 24;
break;
case 27:
+ if ((0x97ffffff97ffffffL & l) != 0L)
+ jjCheckNAddStates(0, 2);
+ break;
case 28:
if ((0x97ffffff97ffffffL & l) != 0L)
jjCheckNAddStates(0, 2);
@@ -383,11 +417,17 @@
jjCheckNAddStates(0, 2);
break;
case 32:
+ if ((0x97ffffff97ffffffL & l) == 0L)
+ break;
+ if (kind > 21)
+ kind = 21;
+ jjCheckNAddTwoStates(33, 34);
+ break;
case 33:
if ((0x97ffffff97ffffffL & l) == 0L)
break;
- if (kind > 20)
- kind = 20;
+ if (kind > 21)
+ kind = 21;
jjCheckNAddTwoStates(33, 34);
break;
case 34:
@@ -397,8 +437,8 @@
case 35:
if ((0x6800000078000000L & l) == 0L)
break;
- if (kind > 20)
- kind = 20;
+ if (kind > 21)
+ kind = 21;
jjCheckNAddTwoStates(33, 34);
break;
case 36:
@@ -420,19 +460,29 @@
{
switch(jjstateSet[--i])
{
+ case 37:
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+ jjCheckNAddStates(0, 2);
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+ {
+ if (kind > 21)
+ kind = 21;
+ jjCheckNAddTwoStates(33, 34);
+ }
+ break;
case 0:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
{
- if (kind > 17)
- kind = 17;
+ if (kind > 18)
+ kind = 18;
jjCheckNAddTwoStates(20, 21);
}
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjCheckNAddStates(0, 2);
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
{
- if (kind > 20)
- kind = 20;
+ if (kind > 21)
+ kind = 21;
jjCheckNAddTwoStates(33, 34);
}
break;
@@ -444,21 +494,30 @@
case 20:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
break;
- if (kind > 17)
- kind = 17;
+ if (kind > 18)
+ kind = 18;
jjCheckNAddTwoStates(20, 21);
break;
case 27:
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+ jjCheckNAddStates(0, 2);
+ break;
case 28:
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
jjCheckNAddStates(0, 2);
break;
case 32:
+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 21)
+ kind = 21;
+ jjCheckNAddTwoStates(33, 34);
+ break;
case 33:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
break;
- if (kind > 20)
- kind = 20;
+ if (kind > 21)
+ kind = 21;
jjCheckNAddTwoStates(33, 34);
break;
default : break;
@@ -483,9 +542,9 @@
switch (pos)
{
case 0:
- if ((active0 & 0x10000000L) != 0L)
+ if ((active0 & 0x20000000L) != 0L)
{
- jjmatchedKind = 31;
+ jjmatchedKind = 32;
return 6;
}
return -1;
@@ -510,9 +569,9 @@
switch(curChar)
{
case 84:
- return jjMoveStringLiteralDfa1_1(0x10000000L);
+ return jjMoveStringLiteralDfa1_1(0x20000000L);
case 125:
- return jjStopAtPos(0, 29);
+ return jjStopAtPos(0, 30);
default :
return jjMoveNfa_1(0, 0);
}
@@ -527,8 +586,8 @@
switch(curChar)
{
case 79:
- if ((active0 & 0x10000000L) != 0L)
- return jjStartNfaWithStates_1(1, 28, 6);
+ if ((active0 & 0x20000000L) != 0L)
+ return jjStartNfaWithStates_1(1, 29, 6);
break;
default :
break;
@@ -557,8 +616,8 @@
case 0:
if ((0xfffffffeffffffffL & l) != 0L)
{
- if (kind > 31)
- kind = 31;
+ if (kind > 32)
+ kind = 32;
jjCheckNAdd(6);
}
if ((0x100002600L & l) != 0L)
@@ -582,14 +641,14 @@
jjCheckNAddStates(11, 13);
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;
@@ -607,8 +666,8 @@
case 6:
if ((0xdfffffffffffffffL & l) == 0L)
break;
- if (kind > 31)
- kind = 31;
+ if (kind > 32)
+ kind = 32;
jjCheckNAdd(6);
break;
case 2:
@@ -637,8 +696,8 @@
case 6:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
break;
- if (kind > 31)
- kind = 31;
+ if (kind > 32)
+ kind = 32;
jjCheckNAdd(6);
break;
case 2:
@@ -688,8 +747,8 @@
case 0:
if ((0x3ff000000000000L & l) == 0L)
break;
- if (kind > 23)
- kind = 23;
+ if (kind > 24)
+ kind = 24;
jjAddStates(14, 15);
break;
case 1:
@@ -699,8 +758,8 @@
case 2:
if ((0x3ff000000000000L & l) == 0L)
break;
- if (kind > 23)
- kind = 23;
+ if (kind > 24)
+ kind = 24;
jjCheckNAdd(2);
break;
default : break;
@@ -751,9 +810,9 @@
switch (pos)
{
case 0:
- if ((active0 & 0x1000000L) != 0L)
+ if ((active0 & 0x2000000L) != 0L)
{
- jjmatchedKind = 27;
+ jjmatchedKind = 28;
return 6;
}
return -1;
@@ -778,9 +837,9 @@
switch(curChar)
{
case 84:
- return jjMoveStringLiteralDfa1_2(0x1000000L);
+ return jjMoveStringLiteralDfa1_2(0x2000000L);
case 93:
- return jjStopAtPos(0, 25);
+ return jjStopAtPos(0, 26);
default :
return jjMoveNfa_2(0, 0);
}
@@ -795,8 +854,8 @@
switch(curChar)
{
case 79:
- if ((active0 & 0x1000000L) != 0L)
- return jjStartNfaWithStates_2(1, 24, 6);
+ if ((active0 & 0x2000000L) != 0L)
+ return jjStartNfaWithStates_2(1, 25, 6);
break;
default :
break;
@@ -825,8 +884,8 @@
case 0:
if ((0xfffffffeffffffffL & l) != 0L)
{
- if (kind > 27)
- kind = 27;
+ if (kind > 28)
+ kind = 28;
jjCheckNAdd(6);
}
if ((0x100002600L & l) != 0L)
@@ -850,14 +909,14 @@
jjCheckNAddStates(11, 13);
break;
case 5:
- if (curChar == 34 && kind > 26)
- kind = 26;
+ if (curChar == 34 && kind > 27)
+ kind = 27;
break;
case 6:
if ((0xfffffffeffffffffL & l) == 0L)
break;
- if (kind > 27)
- kind = 27;
+ if (kind > 28)
+ kind = 28;
jjCheckNAdd(6);
break;
default : break;
@@ -875,8 +934,8 @@
case 6:
if ((0xffffffffdfffffffL & l) == 0L)
break;
- if (kind > 27)
- kind = 27;
+ if (kind > 28)
+ kind = 28;
jjCheckNAdd(6);
break;
case 2:
@@ -905,8 +964,8 @@
case 6:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
break;
- if (kind > 27)
- kind = 27;
+ if (kind > 28)
+ kind = 28;
jjCheckNAdd(6);
break;
case 2:
@@ -947,8 +1006,8 @@
}
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, null, null, null, "\53", "\55", "\50",
-"\51", "\72", "\136", null, null, null, null, null, "\133", "\173", null, "\124\117",
-"\135", null, null, "\124\117", "\175", null, null, };
+"\51", "\72", "\52", "\136", null, null, null, null, null, "\133", "\173", null,
+"\124\117", "\135", null, null, "\124\117", "\175", null, null, };
public static final String[] lexStateNames = {
"Boost",
"RangeEx",
@@ -956,11 +1015,11 @@
"DEFAULT",
};
public static final int[] jjnewLexState = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, 2, 1, 3, -1,
- 3, -1, -1, -1, 3, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, 2, 1, 3,
+ -1, 3, -1, -1, -1, 3, -1, -1,
};
static final long[] jjtoToken = {
- 0xffffff81L,
+ 0x1ffffff81L,
};
static final long[] jjtoSkip = {
0x40L,
Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java?view=diff&rev=480150&r1=480149&r2=480150
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java Tue Nov 28 10:29:28 2006
@@ -30,17 +30,8 @@
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.ConstantScoreRangeQuery;
-import org.apache.lucene.search.FuzzyQuery;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.PhraseQuery;
-import org.apache.lucene.search.PrefixQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RangeQuery;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.WildcardQuery;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.*;
import org.apache.lucene.store.RAMDirectory;
import java.io.IOException;
@@ -674,6 +665,72 @@
assertHits(1, "{12/1/2005 TO 12/4/2005}", is);
assertHits(0, "{12/3/2005 TO 12/4/2005}", is);
is.close();
+ }
+
+ public void testStarParsing() throws Exception {
+ final int[] type = new int[1];
+ QueryParser qp = new QueryParser("field", new WhitespaceAnalyzer()) {
+ protected Query getWildcardQuery(String field, String termStr) throws ParseException {
+ // override error checking of superclass
+ type[0]=1;
+ return new TermQuery(new Term(field,termStr));
+ }
+ protected Query getPrefixQuery(String field, String termStr) throws ParseException {
+ // override error checking of superclass
+ type[0]=2;
+ return new TermQuery(new Term(field,termStr));
+ }
+
+ protected Query getFieldQuery(String field, String queryText) throws ParseException {
+ type[0]=3;
+ return super.getFieldQuery(field, queryText);
+ }
+ };
+
+ TermQuery tq;
+
+ tq = (TermQuery)qp.parse("foo:zoo*");
+ assertEquals("zoo",tq.getTerm().text());
+ assertEquals(2,type[0]);
+
+ tq = (TermQuery)qp.parse("foo:zoo*^2");
+ assertEquals("zoo",tq.getTerm().text());
+ assertEquals(2,type[0]);
+ assertEquals(tq.getBoost(),2,0);
+
+ tq = (TermQuery)qp.parse("foo:*");
+ assertEquals("*",tq.getTerm().text());
+ assertEquals(1,type[0]); // could be a valid prefix query in the future too
+
+ tq = (TermQuery)qp.parse("foo:*^2");
+ assertEquals("*",tq.getTerm().text());
+ assertEquals(1,type[0]);
+ assertEquals(tq.getBoost(),2,0);
+
+ tq = (TermQuery)qp.parse("*:foo");
+ assertEquals("*",tq.getTerm().field());
+ assertEquals("foo",tq.getTerm().text());
+ assertEquals(3,type[0]);
+
+ tq = (TermQuery)qp.parse("*:*");
+ assertEquals("*",tq.getTerm().field());
+ assertEquals("*",tq.getTerm().text());
+ assertEquals(1,type[0]); // could be handled as a prefix query in the future
+
+ tq = (TermQuery)qp.parse("(*:*)");
+ assertEquals("*",tq.getTerm().field());
+ assertEquals("*",tq.getTerm().text());
+ assertEquals(1,type[0]);
+
+ }
+
+ public void testMatchAllDocs() throws Exception {
+ QueryParser qp = new QueryParser("field", new WhitespaceAnalyzer());
+ assertEquals(new MatchAllDocsQuery(), qp.parse("*:*"));
+ assertEquals(new MatchAllDocsQuery(), qp.parse("(*:*)"));
+ BooleanQuery bq = (BooleanQuery)qp.parse("+*:* -*:*");
+ assertTrue(bq.getClauses()[0].getQuery() instanceof MatchAllDocsQuery);
+ assertTrue(bq.getClauses()[1].getQuery() instanceof MatchAllDocsQuery);
}
private void assertHits(int expected, String query, IndexSearcher is) throws ParseException, IOException {