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 classprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final char(package private) static final String(package private) static final charprivate final QueryParser.JJCalls[]private intprivate List<int[]> private int[]private intprivate intprivate intprivate intprivate final int[]private static int[]private Tokenprivate int[]private static final QueryParser.LookaheadSuccessNext token.private intprivate booleanprivate Token(package private) static final int(package private) static final intCurrent token.Generated Token Manager.private boolean(package private) static final String(package private) static final charFields 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 booleanallowedSuffix(String suffixed) protected booleanallowedTruncation(String truncated) final SrndQueryAndQuery()protected static voidcheckDistanceSubQueries(DistanceQuery distq, String opName) final voidDisable tracing.final voidEnable tracing.final SrndQueryGenerate ParseException.protected SrndQuerygetAndQuery(List<SrndQuery> queries, boolean infix, Token andToken) protected SrndQuerygetDistanceQuery(List<SrndQuery> queries, boolean infix, Token dToken, boolean ordered) protected SrndQuerygetFieldsQuery(SrndQuery q, ArrayList<String> fieldNames) final TokenGet the next Token.protected SrndQuerygetNotQuery(List<SrndQuery> queries, Token notToken) protected static intgetOpDistance(String distanceOp) protected SrndQuerygetOrQuery(List<SrndQuery> queries, boolean infix, Token orToken) protected SrndQuerygetPrefixQuery(String prefix, boolean quoted) protected SrndQuerygetTermQuery(String term, boolean quoted) final TokengetToken(int index) Get the specific Token.protected SrndQuerygetTruncQuery(String truncated) private booleanjj_2_1(int xla) private booleanjj_3_1()private voidjj_add_error_token(int kind, int pos) private Tokenjj_consume_token(int kind) private static voidprivate intjj_ntk_f()private voidprivate voidjj_save(int index, int xla) private booleanjj_scan_token(int kind) final SrndQueryNotQuery()final SrndQueryNQuery()final voidfinal SrndQueryOrQuery()static SrndQueryfinal SrndQueryfinal SrndQueryvoidReInit(CharStream stream) Reinitialise.voidReinitialise.final SrndQueryfinal SrndQueryfinal booleanTrace enabled.final SrndQueryWQuery()
-
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)
-