mirror of https://github.com/apache/lucene.git
- LUCENE-489: Add support for leading wildcard characters to QueryParser.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@468291 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
38d2797fa3
commit
7abe11514a
|
@ -22,6 +22,10 @@ Changes in runtime behavior
|
||||||
Also documented some of the ranges.
|
Also documented some of the ranges.
|
||||||
(Otis Gospodnetic)
|
(Otis Gospodnetic)
|
||||||
|
|
||||||
|
4. LUCENE-489: Add support for leading wildcard characters (*, ?) to
|
||||||
|
QueryParser. Default is to disallow them, as before.
|
||||||
|
(Steven Parkes via Otis Gospodnetic)
|
||||||
|
|
||||||
New features
|
New features
|
||||||
|
|
||||||
1. LUCENE-503: New ThaiAnalyzer and ThaiWordFilter in contrib/analyzers
|
1. LUCENE-503: New ThaiAnalyzer and ThaiWordFilter in contrib/analyzers
|
||||||
|
|
|
@ -288,7 +288,9 @@
|
||||||
<fileset dir="src">
|
<fileset dir="src">
|
||||||
<include name="java/org/apache/lucene/analysis/standard/StandardTokenizer.java"/>
|
<include name="java/org/apache/lucene/analysis/standard/StandardTokenizer.java"/>
|
||||||
<include name="java/org/apache/lucene/queryParser/QueryParser.java"/>
|
<include name="java/org/apache/lucene/queryParser/QueryParser.java"/>
|
||||||
|
<include name="java/org/apache/lucene/queryParser/CharStream.java"/>
|
||||||
<include name="demo/org/apache/lucene/demo/html/HTMLParser.java"/>
|
<include name="demo/org/apache/lucene/demo/html/HTMLParser.java"/>
|
||||||
|
<include name="demo/org/apache/lucene/demo/html/SimpleCharStream.java"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</delete>
|
</delete>
|
||||||
</target>
|
</target>
|
||||||
|
|
|
@ -193,6 +193,24 @@ public class SimpleCharStream
|
||||||
return (c);
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see #getEndColumn
|
||||||
|
*/
|
||||||
|
|
||||||
|
public int getColumn() {
|
||||||
|
return bufcolumn[bufpos];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see #getEndLine
|
||||||
|
*/
|
||||||
|
|
||||||
|
public int getLine() {
|
||||||
|
return bufline[bufpos];
|
||||||
|
}
|
||||||
|
|
||||||
public int getEndColumn() {
|
public int getEndColumn() {
|
||||||
return bufcolumn[bufpos];
|
return bufcolumn[bufpos];
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,20 @@ public interface CharStream {
|
||||||
*/
|
*/
|
||||||
char readChar() throws java.io.IOException;
|
char readChar() throws java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the column position of the character last read.
|
||||||
|
* @deprecated
|
||||||
|
* @see #getEndColumn
|
||||||
|
*/
|
||||||
|
int getColumn();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the line number of the character last read.
|
||||||
|
* @deprecated
|
||||||
|
* @see #getEndLine
|
||||||
|
*/
|
||||||
|
int getLine();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the column number of the last character for current token (being
|
* Returns the column number of the last character for current token (being
|
||||||
* matched after the last call to BeginTOken).
|
* matched after the last call to BeginTOken).
|
||||||
|
|
|
@ -82,6 +82,7 @@ public class QueryParser implements QueryParserConstants {
|
||||||
private Operator operator = OR_OPERATOR;
|
private Operator operator = OR_OPERATOR;
|
||||||
|
|
||||||
boolean lowercaseExpandedTerms = true;
|
boolean lowercaseExpandedTerms = true;
|
||||||
|
boolean allowLeadingWildcard = false;
|
||||||
|
|
||||||
Analyzer analyzer;
|
Analyzer analyzer;
|
||||||
String field;
|
String field;
|
||||||
|
@ -194,6 +195,22 @@ public class QueryParser implements QueryParserConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to <code>true</code> to allow <code>*</code> and <code>?</code> as the first character
|
||||||
|
* of a PrefixQuery and WildcardQuery. Note that this can produce very slow
|
||||||
|
* queries on big indexes. Default: false.
|
||||||
|
*/
|
||||||
|
public void setAllowLeadingWildcard(boolean allowLeadingWildcard) {
|
||||||
|
this.allowLeadingWildcard = allowLeadingWildcard;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #setAllowLeadingWildcard
|
||||||
|
*/
|
||||||
|
public boolean getAllowLeadingWildcard() {
|
||||||
|
return allowLeadingWildcard;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the boolean operator of the QueryParser.
|
* Sets the boolean operator of the QueryParser.
|
||||||
* In default mode (<code>OR_OPERATOR</code>) terms without any modifiers
|
* In default mode (<code>OR_OPERATOR</code>) terms without any modifiers
|
||||||
|
@ -506,6 +523,8 @@ public class QueryParser implements QueryParserConstants {
|
||||||
*/
|
*/
|
||||||
protected Query getWildcardQuery(String field, String termStr) throws ParseException
|
protected Query getWildcardQuery(String field, String termStr) throws ParseException
|
||||||
{
|
{
|
||||||
|
if (!allowLeadingWildcard && (termStr.startsWith("*") || termStr.startsWith("?")))
|
||||||
|
throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery");
|
||||||
if (lowercaseExpandedTerms) {
|
if (lowercaseExpandedTerms) {
|
||||||
termStr = termStr.toLowerCase();
|
termStr = termStr.toLowerCase();
|
||||||
}
|
}
|
||||||
|
@ -538,6 +557,8 @@ public class QueryParser implements QueryParserConstants {
|
||||||
*/
|
*/
|
||||||
protected Query getPrefixQuery(String field, String termStr) throws ParseException
|
protected Query getPrefixQuery(String field, String termStr) throws ParseException
|
||||||
{
|
{
|
||||||
|
if (!allowLeadingWildcard && termStr.startsWith("*"))
|
||||||
|
throw new ParseException("'*' not allowed as first character in PrefixQuery");
|
||||||
if (lowercaseExpandedTerms) {
|
if (lowercaseExpandedTerms) {
|
||||||
termStr = termStr.toLowerCase();
|
termStr = termStr.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ public class QueryParser {
|
||||||
private Operator operator = OR_OPERATOR;
|
private Operator operator = OR_OPERATOR;
|
||||||
|
|
||||||
boolean lowercaseExpandedTerms = true;
|
boolean lowercaseExpandedTerms = true;
|
||||||
|
boolean allowLeadingWildcard = false;
|
||||||
|
|
||||||
Analyzer analyzer;
|
Analyzer analyzer;
|
||||||
String field;
|
String field;
|
||||||
|
@ -217,6 +218,22 @@ public class QueryParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to <code>true</code> to allow <code>*</code> and <code>?</code> as the first character
|
||||||
|
* of a PrefixQuery and WildcardQuery. Note that this can produce very slow
|
||||||
|
* queries on big indexes. Default: false.
|
||||||
|
*/
|
||||||
|
public void setAllowLeadingWildcard(boolean allowLeadingWildcard) {
|
||||||
|
this.allowLeadingWildcard = allowLeadingWildcard;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #setAllowLeadingWildcard
|
||||||
|
*/
|
||||||
|
public boolean getAllowLeadingWildcard() {
|
||||||
|
return allowLeadingWildcard;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the boolean operator of the QueryParser.
|
* Sets the boolean operator of the QueryParser.
|
||||||
* In default mode (<code>OR_OPERATOR</code>) terms without any modifiers
|
* In default mode (<code>OR_OPERATOR</code>) terms without any modifiers
|
||||||
|
@ -529,6 +546,8 @@ public class QueryParser {
|
||||||
*/
|
*/
|
||||||
protected Query getWildcardQuery(String field, String termStr) throws ParseException
|
protected Query getWildcardQuery(String field, String termStr) throws ParseException
|
||||||
{
|
{
|
||||||
|
if (!allowLeadingWildcard && (termStr.startsWith("*") || termStr.startsWith("?")))
|
||||||
|
throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery");
|
||||||
if (lowercaseExpandedTerms) {
|
if (lowercaseExpandedTerms) {
|
||||||
termStr = termStr.toLowerCase();
|
termStr = termStr.toLowerCase();
|
||||||
}
|
}
|
||||||
|
@ -561,6 +580,8 @@ public class QueryParser {
|
||||||
*/
|
*/
|
||||||
protected Query getPrefixQuery(String field, String termStr) throws ParseException
|
protected Query getPrefixQuery(String field, String termStr) throws ParseException
|
||||||
{
|
{
|
||||||
|
if (!allowLeadingWildcard && termStr.startsWith("*"))
|
||||||
|
throw new ParseException("'*' not allowed as first character in PrefixQuery");
|
||||||
if (lowercaseExpandedTerms) {
|
if (lowercaseExpandedTerms) {
|
||||||
termStr = termStr.toLowerCase();
|
termStr = termStr.toLowerCase();
|
||||||
}
|
}
|
||||||
|
@ -663,16 +684,6 @@ PARSER_END(QueryParser)
|
||||||
< <_WHITESPACE>>
|
< <_WHITESPACE>>
|
||||||
}
|
}
|
||||||
|
|
||||||
// OG: to support prefix queries:
|
|
||||||
// http://issues.apache.org/bugzilla/show_bug.cgi?id=12137
|
|
||||||
// Change from:
|
|
||||||
//
|
|
||||||
// | <WILDTERM: <_TERM_START_CHAR>
|
|
||||||
// (<_TERM_CHAR> | ( [ "*", "?" ] ))* >
|
|
||||||
// To:
|
|
||||||
//
|
|
||||||
// (<_TERM_START_CHAR> | [ "*", "?" ]) (<_TERM_CHAR> | ( [ "*", "?" ] ))* >
|
|
||||||
|
|
||||||
<DEFAULT> TOKEN : {
|
<DEFAULT> TOKEN : {
|
||||||
<AND: ("AND" | "&&") >
|
<AND: ("AND" | "&&") >
|
||||||
| <OR: ("OR" | "||") >
|
| <OR: ("OR" | "||") >
|
||||||
|
@ -686,9 +697,8 @@ PARSER_END(QueryParser)
|
||||||
| <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>)* "*" >
|
||||||
| <WILDTERM: <_TERM_START_CHAR>
|
| <WILDTERM: (<_TERM_START_CHAR> | [ "*", "?" ]) (<_TERM_CHAR> | ( [ "*", "?" ] ))* >
|
||||||
(<_TERM_CHAR> | ( [ "*", "?" ] ))* >
|
|
||||||
| <RANGEIN_START: "[" > : RangeIn
|
| <RANGEIN_START: "[" > : RangeIn
|
||||||
| <RANGEEX_START: "{" > : RangeEx
|
| <RANGEEX_START: "{" > : RangeEx
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ private final int jjMoveNfa_3(int startState, int curPos)
|
||||||
{
|
{
|
||||||
int[] nextStates;
|
int[] nextStates;
|
||||||
int startsAt = 0;
|
int startsAt = 0;
|
||||||
jjnewStateCnt = 33;
|
jjnewStateCnt = 35;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
jjstateSet[0] = startState;
|
jjstateSet[0] = startState;
|
||||||
int j, kind = 0x7fffffff;
|
int j, kind = 0x7fffffff;
|
||||||
|
@ -120,11 +120,11 @@ private final int jjMoveNfa_3(int startState, int curPos)
|
||||||
switch(jjstateSet[--i])
|
switch(jjstateSet[--i])
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if ((0x7bffd0f8ffffd9ffL & l) != 0L)
|
if ((0xfbffd4f8ffffd9ffL & l) != 0L)
|
||||||
{
|
{
|
||||||
if (kind > 17)
|
if (kind > 20)
|
||||||
kind = 17;
|
kind = 20;
|
||||||
jjCheckNAddStates(0, 6);
|
jjCheckNAddTwoStates(31, 32);
|
||||||
}
|
}
|
||||||
else if ((0x100002600L & l) != 0L)
|
else if ((0x100002600L & l) != 0L)
|
||||||
{
|
{
|
||||||
|
@ -138,6 +138,14 @@ private final int jjMoveNfa_3(int startState, int curPos)
|
||||||
if (kind > 9)
|
if (kind > 9)
|
||||||
kind = 9;
|
kind = 9;
|
||||||
}
|
}
|
||||||
|
if ((0x7bffd4f8ffffd9ffL & l) != 0L)
|
||||||
|
jjCheckNAddStates(0, 2);
|
||||||
|
if ((0x7bffd0f8ffffd9ffL & l) != 0L)
|
||||||
|
{
|
||||||
|
if (kind > 17)
|
||||||
|
kind = 17;
|
||||||
|
jjCheckNAddTwoStates(18, 19);
|
||||||
|
}
|
||||||
if (curChar == 38)
|
if (curChar == 38)
|
||||||
jjstateSet[jjnewStateCnt++] = 4;
|
jjstateSet[jjnewStateCnt++] = 4;
|
||||||
break;
|
break;
|
||||||
|
@ -165,70 +173,81 @@ private final int jjMoveNfa_3(int startState, int curPos)
|
||||||
if (curChar == 34 && kind > 16)
|
if (curChar == 34 && kind > 16)
|
||||||
kind = 16;
|
kind = 16;
|
||||||
break;
|
break;
|
||||||
case 18:
|
case 17:
|
||||||
if ((0x3ff000000000000L & l) == 0L)
|
|
||||||
break;
|
|
||||||
if (kind > 18)
|
|
||||||
kind = 18;
|
|
||||||
jjAddStates(7, 8);
|
|
||||||
break;
|
|
||||||
case 19:
|
|
||||||
if (curChar == 46)
|
|
||||||
jjCheckNAdd(20);
|
|
||||||
break;
|
|
||||||
case 20:
|
|
||||||
if ((0x3ff000000000000L & l) == 0L)
|
|
||||||
break;
|
|
||||||
if (kind > 18)
|
|
||||||
kind = 18;
|
|
||||||
jjCheckNAdd(20);
|
|
||||||
break;
|
|
||||||
case 21:
|
|
||||||
if ((0x7bffd0f8ffffd9ffL & l) == 0L)
|
if ((0x7bffd0f8ffffd9ffL & l) == 0L)
|
||||||
break;
|
break;
|
||||||
if (kind > 17)
|
if (kind > 17)
|
||||||
kind = 17;
|
kind = 17;
|
||||||
jjCheckNAddStates(0, 6);
|
jjCheckNAddTwoStates(18, 19);
|
||||||
break;
|
break;
|
||||||
case 22:
|
case 18:
|
||||||
if ((0x7bfff8f8ffffd9ffL & l) == 0L)
|
if ((0x7bfff8f8ffffd9ffL & l) == 0L)
|
||||||
break;
|
break;
|
||||||
if (kind > 17)
|
if (kind > 17)
|
||||||
kind = 17;
|
kind = 17;
|
||||||
jjCheckNAddTwoStates(22, 23);
|
jjCheckNAddTwoStates(18, 19);
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 20:
|
||||||
if ((0x84002f0600000000L & l) == 0L)
|
if ((0x84002f0600000000L & l) == 0L)
|
||||||
break;
|
break;
|
||||||
if (kind > 17)
|
if (kind > 17)
|
||||||
kind = 17;
|
kind = 17;
|
||||||
jjCheckNAddTwoStates(22, 23);
|
jjCheckNAddTwoStates(18, 19);
|
||||||
|
break;
|
||||||
|
case 22:
|
||||||
|
if ((0x3ff000000000000L & l) == 0L)
|
||||||
|
break;
|
||||||
|
if (kind > 18)
|
||||||
|
kind = 18;
|
||||||
|
jjAddStates(3, 4);
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
if (curChar == 46)
|
||||||
|
jjCheckNAdd(24);
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
if ((0x3ff000000000000L & l) == 0L)
|
||||||
|
break;
|
||||||
|
if (kind > 18)
|
||||||
|
kind = 18;
|
||||||
|
jjCheckNAdd(24);
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
if ((0x7bfff8f8ffffd9ffL & l) != 0L)
|
if ((0x7bffd4f8ffffd9ffL & l) != 0L)
|
||||||
jjCheckNAddStates(9, 11);
|
jjCheckNAddStates(0, 2);
|
||||||
break;
|
break;
|
||||||
case 26:
|
case 26:
|
||||||
|
if ((0x7bfff8f8ffffd9ffL & l) != 0L)
|
||||||
|
jjCheckNAddStates(0, 2);
|
||||||
|
break;
|
||||||
|
case 27:
|
||||||
if (curChar == 42 && kind > 19)
|
if (curChar == 42 && kind > 19)
|
||||||
kind = 19;
|
kind = 19;
|
||||||
break;
|
break;
|
||||||
case 28:
|
|
||||||
if ((0x84002f0600000000L & l) != 0L)
|
|
||||||
jjCheckNAddStates(9, 11);
|
|
||||||
break;
|
|
||||||
case 29:
|
case 29:
|
||||||
|
if ((0x84002f0600000000L & l) != 0L)
|
||||||
|
jjCheckNAddStates(0, 2);
|
||||||
|
break;
|
||||||
|
case 30:
|
||||||
|
if ((0xfbffd4f8ffffd9ffL & l) == 0L)
|
||||||
|
break;
|
||||||
|
if (kind > 20)
|
||||||
|
kind = 20;
|
||||||
|
jjCheckNAddTwoStates(31, 32);
|
||||||
|
break;
|
||||||
|
case 31:
|
||||||
if ((0xfbfffcf8ffffd9ffL & l) == 0L)
|
if ((0xfbfffcf8ffffd9ffL & l) == 0L)
|
||||||
break;
|
break;
|
||||||
if (kind > 20)
|
if (kind > 20)
|
||||||
kind = 20;
|
kind = 20;
|
||||||
jjCheckNAddTwoStates(29, 30);
|
jjCheckNAddTwoStates(31, 32);
|
||||||
break;
|
break;
|
||||||
case 31:
|
case 33:
|
||||||
if ((0x84002f0600000000L & l) == 0L)
|
if ((0x84002f0600000000L & l) == 0L)
|
||||||
break;
|
break;
|
||||||
if (kind > 20)
|
if (kind > 20)
|
||||||
kind = 20;
|
kind = 20;
|
||||||
jjCheckNAddTwoStates(29, 30);
|
jjCheckNAddTwoStates(31, 32);
|
||||||
break;
|
break;
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
|
@ -244,18 +263,26 @@ private final int jjMoveNfa_3(int startState, int curPos)
|
||||||
case 0:
|
case 0:
|
||||||
if ((0x97ffffff97ffffffL & l) != 0L)
|
if ((0x97ffffff97ffffffL & l) != 0L)
|
||||||
{
|
{
|
||||||
if (kind > 17)
|
if (kind > 20)
|
||||||
kind = 17;
|
kind = 20;
|
||||||
jjCheckNAddStates(0, 6);
|
jjCheckNAddTwoStates(31, 32);
|
||||||
}
|
}
|
||||||
else if (curChar == 126)
|
else if (curChar == 126)
|
||||||
{
|
{
|
||||||
if (kind > 18)
|
if (kind > 18)
|
||||||
kind = 18;
|
kind = 18;
|
||||||
jjstateSet[jjnewStateCnt++] = 18;
|
jjstateSet[jjnewStateCnt++] = 22;
|
||||||
|
}
|
||||||
|
if ((0x97ffffff97ffffffL & l) != 0L)
|
||||||
|
jjCheckNAddStates(0, 2);
|
||||||
|
if ((0x97ffffff97ffffffL & l) != 0L)
|
||||||
|
{
|
||||||
|
if (kind > 17)
|
||||||
|
kind = 17;
|
||||||
|
jjCheckNAddTwoStates(18, 19);
|
||||||
}
|
}
|
||||||
if (curChar == 92)
|
if (curChar == 92)
|
||||||
jjCheckNAddStates(12, 14);
|
jjCheckNAddStates(5, 7);
|
||||||
else if (curChar == 78)
|
else if (curChar == 78)
|
||||||
jjstateSet[jjnewStateCnt++] = 11;
|
jjstateSet[jjnewStateCnt++] = 11;
|
||||||
else if (curChar == 124)
|
else if (curChar == 124)
|
||||||
|
@ -306,73 +333,69 @@ private final int jjMoveNfa_3(int startState, int curPos)
|
||||||
jjstateSet[jjnewStateCnt++] = 11;
|
jjstateSet[jjnewStateCnt++] = 11;
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
jjAddStates(15, 16);
|
jjAddStates(8, 9);
|
||||||
break;
|
break;
|
||||||
case 17:
|
case 17:
|
||||||
|
case 18:
|
||||||
|
if ((0x97ffffff97ffffffL & l) == 0L)
|
||||||
|
break;
|
||||||
|
if (kind > 17)
|
||||||
|
kind = 17;
|
||||||
|
jjCheckNAddTwoStates(18, 19);
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
if (curChar == 92)
|
||||||
|
jjCheckNAddTwoStates(20, 20);
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
if ((0x6800000078000000L & l) == 0L)
|
||||||
|
break;
|
||||||
|
if (kind > 17)
|
||||||
|
kind = 17;
|
||||||
|
jjCheckNAddTwoStates(18, 19);
|
||||||
|
break;
|
||||||
|
case 21:
|
||||||
if (curChar != 126)
|
if (curChar != 126)
|
||||||
break;
|
break;
|
||||||
if (kind > 18)
|
if (kind > 18)
|
||||||
kind = 18;
|
kind = 18;
|
||||||
jjstateSet[jjnewStateCnt++] = 18;
|
jjstateSet[jjnewStateCnt++] = 22;
|
||||||
break;
|
|
||||||
case 21:
|
|
||||||
if ((0x97ffffff97ffffffL & l) == 0L)
|
|
||||||
break;
|
|
||||||
if (kind > 17)
|
|
||||||
kind = 17;
|
|
||||||
jjCheckNAddStates(0, 6);
|
|
||||||
break;
|
|
||||||
case 22:
|
|
||||||
if ((0x97ffffff97ffffffL & l) == 0L)
|
|
||||||
break;
|
|
||||||
if (kind > 17)
|
|
||||||
kind = 17;
|
|
||||||
jjCheckNAddTwoStates(22, 23);
|
|
||||||
break;
|
|
||||||
case 23:
|
|
||||||
if (curChar == 92)
|
|
||||||
jjCheckNAddTwoStates(24, 24);
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
if ((0x6800000078000000L & l) == 0L)
|
|
||||||
break;
|
|
||||||
if (kind > 17)
|
|
||||||
kind = 17;
|
|
||||||
jjCheckNAddTwoStates(22, 23);
|
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
|
case 26:
|
||||||
if ((0x97ffffff97ffffffL & l) != 0L)
|
if ((0x97ffffff97ffffffL & l) != 0L)
|
||||||
jjCheckNAddStates(9, 11);
|
jjCheckNAddStates(0, 2);
|
||||||
break;
|
|
||||||
case 27:
|
|
||||||
if (curChar == 92)
|
|
||||||
jjCheckNAddTwoStates(28, 28);
|
|
||||||
break;
|
break;
|
||||||
case 28:
|
case 28:
|
||||||
if ((0x6800000078000000L & l) != 0L)
|
if (curChar == 92)
|
||||||
jjCheckNAddStates(9, 11);
|
jjCheckNAddTwoStates(29, 29);
|
||||||
break;
|
break;
|
||||||
case 29:
|
case 29:
|
||||||
|
if ((0x6800000078000000L & l) != 0L)
|
||||||
|
jjCheckNAddStates(0, 2);
|
||||||
|
break;
|
||||||
|
case 30:
|
||||||
|
case 31:
|
||||||
if ((0x97ffffff97ffffffL & l) == 0L)
|
if ((0x97ffffff97ffffffL & l) == 0L)
|
||||||
break;
|
break;
|
||||||
if (kind > 20)
|
if (kind > 20)
|
||||||
kind = 20;
|
kind = 20;
|
||||||
jjCheckNAddTwoStates(29, 30);
|
jjCheckNAddTwoStates(31, 32);
|
||||||
break;
|
|
||||||
case 30:
|
|
||||||
if (curChar == 92)
|
|
||||||
jjCheckNAddTwoStates(31, 31);
|
|
||||||
break;
|
|
||||||
case 31:
|
|
||||||
if ((0x6800000078000000L & l) == 0L)
|
|
||||||
break;
|
|
||||||
if (kind > 20)
|
|
||||||
kind = 20;
|
|
||||||
jjCheckNAddTwoStates(29, 30);
|
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
if (curChar == 92)
|
if (curChar == 92)
|
||||||
jjCheckNAddStates(12, 14);
|
jjCheckNAddTwoStates(33, 33);
|
||||||
|
break;
|
||||||
|
case 33:
|
||||||
|
if ((0x6800000078000000L & l) == 0L)
|
||||||
|
break;
|
||||||
|
if (kind > 20)
|
||||||
|
kind = 20;
|
||||||
|
jjCheckNAddTwoStates(31, 32);
|
||||||
|
break;
|
||||||
|
case 34:
|
||||||
|
if (curChar == 92)
|
||||||
|
jjCheckNAddStates(5, 7);
|
||||||
break;
|
break;
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
|
@ -390,33 +413,45 @@ private final int jjMoveNfa_3(int startState, int curPos)
|
||||||
switch(jjstateSet[--i])
|
switch(jjstateSet[--i])
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
|
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
||||||
break;
|
{
|
||||||
if (kind > 17)
|
if (kind > 17)
|
||||||
kind = 17;
|
kind = 17;
|
||||||
jjCheckNAddStates(0, 6);
|
jjCheckNAddTwoStates(18, 19);
|
||||||
|
}
|
||||||
|
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
||||||
|
jjCheckNAddStates(0, 2);
|
||||||
|
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
||||||
|
{
|
||||||
|
if (kind > 20)
|
||||||
|
kind = 20;
|
||||||
|
jjCheckNAddTwoStates(31, 32);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
||||||
jjAddStates(15, 16);
|
jjAddStates(8, 9);
|
||||||
break;
|
break;
|
||||||
case 22:
|
case 17:
|
||||||
|
case 18:
|
||||||
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
|
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
|
||||||
break;
|
break;
|
||||||
if (kind > 17)
|
if (kind > 17)
|
||||||
kind = 17;
|
kind = 17;
|
||||||
jjCheckNAddTwoStates(22, 23);
|
jjCheckNAddTwoStates(18, 19);
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
|
case 26:
|
||||||
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
||||||
jjCheckNAddStates(9, 11);
|
jjCheckNAddStates(0, 2);
|
||||||
break;
|
break;
|
||||||
case 29:
|
case 30:
|
||||||
|
case 31:
|
||||||
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
|
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
|
||||||
break;
|
break;
|
||||||
if (kind > 20)
|
if (kind > 20)
|
||||||
kind = 20;
|
kind = 20;
|
||||||
jjCheckNAddTwoStates(29, 30);
|
jjCheckNAddTwoStates(31, 32);
|
||||||
break;
|
break;
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
|
@ -429,7 +464,7 @@ private final int jjMoveNfa_3(int startState, int curPos)
|
||||||
kind = 0x7fffffff;
|
kind = 0x7fffffff;
|
||||||
}
|
}
|
||||||
++curPos;
|
++curPos;
|
||||||
if ((i = jjnewStateCnt) == (startsAt = 33 - (jjnewStateCnt = startsAt)))
|
if ((i = jjnewStateCnt) == (startsAt = 35 - (jjnewStateCnt = startsAt)))
|
||||||
return curPos;
|
return curPos;
|
||||||
try { curChar = input_stream.readChar(); }
|
try { curChar = input_stream.readChar(); }
|
||||||
catch(java.io.IOException e) { return curPos; }
|
catch(java.io.IOException e) { return curPos; }
|
||||||
|
@ -565,7 +600,7 @@ private final int jjMoveNfa_1(int startState, int curPos)
|
||||||
jjCheckNAdd(4);
|
jjCheckNAdd(4);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
jjAddStates(17, 18);
|
jjAddStates(10, 11);
|
||||||
break;
|
break;
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
|
@ -592,7 +627,7 @@ private final int jjMoveNfa_1(int startState, int curPos)
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
||||||
jjAddStates(17, 18);
|
jjAddStates(10, 11);
|
||||||
break;
|
break;
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
|
@ -639,7 +674,7 @@ private final int jjMoveNfa_0(int startState, int curPos)
|
||||||
break;
|
break;
|
||||||
if (kind > 23)
|
if (kind > 23)
|
||||||
kind = 23;
|
kind = 23;
|
||||||
jjAddStates(19, 20);
|
jjAddStates(12, 13);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (curChar == 46)
|
if (curChar == 46)
|
||||||
|
@ -825,7 +860,7 @@ private final int jjMoveNfa_2(int startState, int curPos)
|
||||||
jjCheckNAdd(4);
|
jjCheckNAdd(4);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
jjAddStates(17, 18);
|
jjAddStates(10, 11);
|
||||||
break;
|
break;
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
|
@ -852,7 +887,7 @@ private final int jjMoveNfa_2(int startState, int curPos)
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
if (jjCanMove_0(hiByte, i1, i2, l1, l2))
|
||||||
jjAddStates(17, 18);
|
jjAddStates(10, 11);
|
||||||
break;
|
break;
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
|
@ -872,8 +907,7 @@ private final int jjMoveNfa_2(int startState, int curPos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static final int[] jjnextStates = {
|
static final int[] jjnextStates = {
|
||||||
22, 25, 26, 29, 30, 27, 23, 18, 19, 25, 26, 27, 24, 28, 31, 15,
|
26, 27, 28, 22, 23, 20, 29, 33, 15, 16, 2, 3, 0, 1,
|
||||||
16, 2, 3, 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)
|
||||||
{
|
{
|
||||||
|
@ -908,8 +942,8 @@ static final long[] jjtoSkip = {
|
||||||
0x40L,
|
0x40L,
|
||||||
};
|
};
|
||||||
protected CharStream input_stream;
|
protected CharStream input_stream;
|
||||||
private final int[] jjrounds = new int[33];
|
private final int[] jjrounds = new int[35];
|
||||||
private final int[] jjstateSet = new int[66];
|
private final int[] jjstateSet = new int[70];
|
||||||
protected char curChar;
|
protected char curChar;
|
||||||
public QueryParserTokenManager(CharStream stream)
|
public QueryParserTokenManager(CharStream stream)
|
||||||
{
|
{
|
||||||
|
@ -931,7 +965,7 @@ private final void ReInitRounds()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
jjround = 0x80000001;
|
jjround = 0x80000001;
|
||||||
for (i = 33; i-- > 0;)
|
for (i = 35; i-- > 0;)
|
||||||
jjrounds[i] = 0x80000000;
|
jjrounds[i] = 0x80000000;
|
||||||
}
|
}
|
||||||
public void ReInit(CharStream stream, int lexState)
|
public void ReInit(CharStream stream, int lexState)
|
||||||
|
|
|
@ -143,10 +143,11 @@ public class TestQueryParser extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertWildcardQueryEquals(String query, boolean lowercase, String result)
|
public void assertWildcardQueryEquals(String query, boolean lowercase, String result, boolean allowLeadingWildcard)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
QueryParser qp = getParser(null);
|
QueryParser qp = getParser(null);
|
||||||
qp.setLowercaseExpandedTerms(lowercase);
|
qp.setLowercaseExpandedTerms(lowercase);
|
||||||
|
qp.setAllowLeadingWildcard(allowLeadingWildcard);
|
||||||
Query q = qp.parse(query);
|
Query q = qp.parse(query);
|
||||||
String s = q.toString("field");
|
String s = q.toString("field");
|
||||||
if (!s.equals(result)) {
|
if (!s.equals(result)) {
|
||||||
|
@ -155,6 +156,11 @@ public class TestQueryParser extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void assertWildcardQueryEquals(String query, boolean lowercase, String result)
|
||||||
|
throws Exception {
|
||||||
|
assertWildcardQueryEquals(query, lowercase, result, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void assertWildcardQueryEquals(String query, String result) throws Exception {
|
public void assertWildcardQueryEquals(String query, String result) throws Exception {
|
||||||
QueryParser qp = getParser(null);
|
QueryParser qp = getParser(null);
|
||||||
Query q = qp.parse(query);
|
Query q = qp.parse(query);
|
||||||
|
@ -330,6 +336,22 @@ public class TestQueryParser extends TestCase {
|
||||||
assertWildcardQueryEquals("[A TO C]", "[a TO c]");
|
assertWildcardQueryEquals("[A TO C]", "[a TO c]");
|
||||||
assertWildcardQueryEquals("[A TO C]", true, "[a TO c]");
|
assertWildcardQueryEquals("[A TO C]", true, "[a TO c]");
|
||||||
assertWildcardQueryEquals("[A TO C]", false, "[A TO C]");
|
assertWildcardQueryEquals("[A TO C]", false, "[A TO C]");
|
||||||
|
// Test suffix queries: first disallow
|
||||||
|
try {
|
||||||
|
assertWildcardQueryEquals("*Term", true, "*term");
|
||||||
|
fail();
|
||||||
|
} catch(ParseException pe) {
|
||||||
|
// expected exception
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
assertWildcardQueryEquals("?Term", true, "?term");
|
||||||
|
fail();
|
||||||
|
} catch(ParseException pe) {
|
||||||
|
// expected exception
|
||||||
|
}
|
||||||
|
// Test suffix queries: then allow
|
||||||
|
assertWildcardQueryEquals("*Term", true, "*term", true);
|
||||||
|
assertWildcardQueryEquals("?Term", true, "?term", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testQPA() throws Exception {
|
public void testQPA() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue