mirror of https://github.com/apache/lucene.git
Changed so that PrefixQuery is used in preference to WildcardQuery
when there's only an asterisk at the end of the term. Previously PrefixQuery would never be used. Also removed some unused token rules. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149618 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
49bd4164b8
commit
4a8ecc08c0
|
@ -254,15 +254,10 @@ PARSER_END(QueryParser)
|
||||||
/* ***************** */
|
/* ***************** */
|
||||||
|
|
||||||
<*> TOKEN : {
|
<*> TOKEN : {
|
||||||
<#_ALPHA_CHAR: ["a"-"z", "A"-"Z"] >
|
<#_NUM_CHAR: ["0"-"9"] >
|
||||||
| <#_NUM_CHAR: ["0"-"9"] >
|
|
||||||
| <#_ALPHANUM_CHAR: [ "a"-"z", "A"-"Z", "0"-"9" ] >
|
|
||||||
| <#_TERM_START_CHAR: [ "a"-"z", "A"-"Z", "_", "\u0080"-"\uFFFE" ] >
|
| <#_TERM_START_CHAR: [ "a"-"z", "A"-"Z", "_", "\u0080"-"\uFFFE" ] >
|
||||||
| <#_TERM_CHAR: [ "a"-"z", "A"-"Z", "0"-"9", "_", "\u0080"-"\uFFFE" ] >
|
| <#_TERM_CHAR: [ "a"-"z", "A"-"Z", "0"-"9", "_", "\u0080"-"\uFFFE" ] >
|
||||||
| <#_NEWLINE: ( "\r\n" | "\r" | "\n" ) >
|
|
||||||
| <#_WHITESPACE: ( " " | "\t" ) >
|
| <#_WHITESPACE: ( " " | "\t" ) >
|
||||||
| <#_QCHAR: ( "\\" (<_NEWLINE> | ~["a"-"z", "A"-"Z", "0"-"9"] ) ) >
|
|
||||||
| <#_RESTOFLINE: (~["\r", "\n"])* >
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<DEFAULT> TOKEN : {
|
<DEFAULT> TOKEN : {
|
||||||
|
@ -275,11 +270,11 @@ PARSER_END(QueryParser)
|
||||||
| <RPAREN: ")" >
|
| <RPAREN: ")" >
|
||||||
| <COLON: ":" >
|
| <COLON: ":" >
|
||||||
| <CARAT: "^" >
|
| <CARAT: "^" >
|
||||||
| <STAR: "*" >
|
|
||||||
| <QUOTED: "\"" (~["\""])+ "\"">
|
| <QUOTED: "\"" (~["\""])+ "\"">
|
||||||
| <NUMBER: (<_NUM_CHAR>)+ ( "." (<_NUM_CHAR>)+ )? >
|
| <NUMBER: (<_NUM_CHAR>)+ ( "." (<_NUM_CHAR>)+ )? >
|
||||||
| <TERM: <_TERM_START_CHAR> (<_TERM_CHAR>)* >
|
| <TERM: <_TERM_START_CHAR> (<_TERM_CHAR>)* >
|
||||||
| <FUZZY: "~" >
|
| <FUZZY: "~" >
|
||||||
|
| <PREFIXTERM: <_TERM_START_CHAR> (<_TERM_CHAR>)* "*" >
|
||||||
| <WILDTERM: <_TERM_START_CHAR>
|
| <WILDTERM: <_TERM_START_CHAR>
|
||||||
(<_TERM_CHAR> | ( [ "*", "?" ] ))* >
|
(<_TERM_CHAR> | ( [ "*", "?" ] ))* >
|
||||||
| <RANGEIN: "[" (~["]"])+ "]">
|
| <RANGEIN: "[" (~["]"])+ "]">
|
||||||
|
@ -369,16 +364,18 @@ Query Term(String field) : {
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
term=<TERM>
|
term=<TERM>
|
||||||
|
| term=<PREFIXTERM> { prefix=true; }
|
||||||
| term=<WILDTERM> { wildcard=true; }
|
| term=<WILDTERM> { wildcard=true; }
|
||||||
| term=<NUMBER>
|
| term=<NUMBER>
|
||||||
)
|
)
|
||||||
[ <STAR> { prefix=true; } | <FUZZY> { fuzzy=true; } ]
|
[ <FUZZY> { fuzzy=true; } ]
|
||||||
[ <CARAT> boost=<NUMBER> ]
|
[ <CARAT> boost=<NUMBER> ]
|
||||||
{
|
{
|
||||||
if (wildcard)
|
if (wildcard)
|
||||||
q = new WildcardQuery(new Term(field, term.image));
|
q = new WildcardQuery(new Term(field, term.image));
|
||||||
else if (prefix)
|
else if (prefix)
|
||||||
q = new PrefixQuery(new Term(field, term.image));
|
q = new PrefixQuery(new Term(field, term.image.substring
|
||||||
|
(0, term.image.length()-1)));
|
||||||
else if (fuzzy)
|
else if (fuzzy)
|
||||||
q = new FuzzyQuery(new Term(field, term.image));
|
q = new FuzzyQuery(new Term(field, term.image));
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue