Class QueryParser
- All Implemented Interfaces:
QueryParserConstants
parse()
.
This parser generates queries that make use of position information
(Span queries). It provides positional operators (w
and
n
) that accept a numeric distance, as well as boolean
operators (and
, or
, and not
,
wildcards (*
and ?
), quoting (with
"
), and boosting (via ^
).
The operators (W, N, AND, OR, NOT) can be expressed lower-cased or
upper-cased, and the non-unary operators (everything but NOT) support
both infix (a AND b AND c)
and prefix AND(a, b,
c)
notation.
The W and N operators express a positional relationship among their operands. W is ordered, and N is unordered. The distance is 1 by default, meaning the operands are adjacent, or may be provided as a prefix from 2-99. So, for example, 3W(a, b) means that terms a and b must appear within three positions of each other, or in other words, up to two terms may appear between a and b.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final char
(package private) static final String
(package private) static final char
private final QueryParser.JJCalls[]
private int
private List<int[]>
private int[]
private int
private int
private int
private int
private final int[]
private static int[]
private Token
private int[]
private static final QueryParser.LookaheadSuccess
Next token.private int
private boolean
private Token
(package private) static final int
(package private) static final int
Current token.Generated Token Manager.private boolean
(package private) static final String
(package private) static final char
Fields inherited from interface org.apache.lucene.queryparser.surround.parser.QueryParserConstants
_DISTOP_NUM, _NUM_CHAR, _ONE_CHAR, _STAR, _TERM_CHAR, _WHITESPACE, AND, Boost, CARAT, COLON, COMMA, DEFAULT, EOF, LPAREN, N, NOT, NUMBER, OR, QUOTED, RPAREN, SUFFIXTERM, TERM, tokenImage, TRUNCQUOTED, TRUNCTERM, W
-
Constructor Summary
ConstructorsConstructorDescriptionQueryParser
(CharStream stream) Constructor with user supplied CharStream.Constructor with generated Token Manager. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
allowedSuffix
(String suffixed) protected boolean
allowedTruncation
(String truncated) final SrndQuery
AndQuery()
protected static void
checkDistanceSubQueries
(DistanceQuery distq, String opName) final void
Disable tracing.final void
Enable tracing.final SrndQuery
Generate ParseException.protected SrndQuery
getAndQuery
(List<SrndQuery> queries, boolean infix, Token andToken) protected SrndQuery
getDistanceQuery
(List<SrndQuery> queries, boolean infix, Token dToken, boolean ordered) protected SrndQuery
getFieldsQuery
(SrndQuery q, ArrayList<String> fieldNames) final Token
Get the next Token.protected SrndQuery
getNotQuery
(List<SrndQuery> queries, Token notToken) protected static int
getOpDistance
(String distanceOp) protected SrndQuery
getOrQuery
(List<SrndQuery> queries, boolean infix, Token orToken) protected SrndQuery
getPrefixQuery
(String prefix, boolean quoted) protected SrndQuery
getTermQuery
(String term, boolean quoted) final Token
getToken
(int index) Get the specific Token.protected SrndQuery
getTruncQuery
(String truncated) private boolean
jj_2_1
(int xla) private boolean
jj_3_1()
private void
jj_add_error_token
(int kind, int pos) private Token
jj_consume_token
(int kind) private static void
private int
jj_ntk_f()
private void
private void
jj_save
(int index, int xla) private boolean
jj_scan_token
(int kind) final SrndQuery
NotQuery()
final SrndQuery
NQuery()
final void
final SrndQuery
OrQuery()
static SrndQuery
final SrndQuery
final SrndQuery
void
ReInit
(CharStream stream) Reinitialise.void
Reinitialise.final SrndQuery
final SrndQuery
final boolean
Trace enabled.final SrndQuery
WQuery()
-
Field Details
-
MINIMUM_PREFIX_LENGTH
static final int MINIMUM_PREFIX_LENGTH- See Also:
-
MINIMUM_CHARS_IN_TRUNC
static final int MINIMUM_CHARS_IN_TRUNC- See Also:
-
TRUNCATION_ERROR_MESSAGE
- See Also:
-
BOOST_ERROR_MESSAGE
- See Also:
-
TRUNCATOR
static final char TRUNCATOR- See Also:
-
ANY_CHAR
static final char ANY_CHAR- See Also:
-
FIELD_OPERATOR
static final char FIELD_OPERATOR- See Also:
-
token_source
Generated Token Manager. -
token
Current token. -
jj_nt
Next token. -
jj_ntk
private int jj_ntk -
jj_scanpos
-
jj_lastpos
-
jj_la
private int jj_la -
jj_gen
private int jj_gen -
jj_la1
private final int[] jj_la1 -
jj_la1_0
private static int[] jj_la1_0 -
jj_2_rtns
-
jj_rescan
private boolean jj_rescan -
jj_gc
private int jj_gc -
jj_ls
-
jj_expentries
-
jj_expentry
private int[] jj_expentry -
jj_kind
private int jj_kind -
jj_lasttokens
private int[] jj_lasttokens -
jj_endpos
private int jj_endpos -
trace_enabled
private boolean trace_enabled
-
-
Constructor Details
-
QueryParser
public QueryParser() -
QueryParser
Constructor with user supplied CharStream. -
QueryParser
Constructor with generated Token Manager.
-
-
Method Details
-
parse
- Throws:
ParseException
-
parse2
- Throws:
ParseException
-
getFieldsQuery
-
getOrQuery
-
getAndQuery
-
getNotQuery
-
getOpDistance
-
checkDistanceSubQueries
protected static void checkDistanceSubQueries(DistanceQuery distq, String opName) throws ParseException - Throws:
ParseException
-
getDistanceQuery
protected SrndQuery getDistanceQuery(List<SrndQuery> queries, boolean infix, Token dToken, boolean ordered) throws ParseException - Throws:
ParseException
-
getTermQuery
-
allowedSuffix
-
getPrefixQuery
-
allowedTruncation
-
getTruncQuery
-
TopSrndQuery
- Throws:
ParseException
-
FieldsQuery
- Throws:
ParseException
-
OptionalFields
- Throws:
ParseException
-
OrQuery
- Throws:
ParseException
-
AndQuery
- Throws:
ParseException
-
NotQuery
- Throws:
ParseException
-
NQuery
- Throws:
ParseException
-
WQuery
- Throws:
ParseException
-
PrimaryQuery
- Throws:
ParseException
-
PrefixOperatorQuery
- Throws:
ParseException
-
FieldsQueryList
- Throws:
ParseException
-
SimpleTerm
- Throws:
ParseException
-
OptionalWeights
- Throws:
ParseException
-
jj_2_1
private boolean jj_2_1(int xla) -
jj_3_1
private boolean jj_3_1() -
jj_la1_init_0
private static void jj_la1_init_0() -
ReInit
Reinitialise. -
ReInit
Reinitialise. -
jj_consume_token
- Throws:
ParseException
-
jj_scan_token
private boolean jj_scan_token(int kind) -
getNextToken
Get the next Token. -
getToken
Get the specific Token. -
jj_ntk_f
private int jj_ntk_f() -
jj_add_error_token
private void jj_add_error_token(int kind, int pos) -
generateParseException
Generate ParseException. -
trace_enabled
public final boolean trace_enabled()Trace enabled. -
enable_tracing
public final void enable_tracing()Enable tracing. -
disable_tracing
public final void disable_tracing()Disable tracing. -
jj_rescan_token
private void jj_rescan_token() -
jj_save
private void jj_save(int index, int xla)
-