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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionNext token.Current token.Generated Token Manager.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 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) final SrndQueryNotQuery()final SrndQueryNQuery()final voidfinal SrndQueryOrQuery()static SrndQueryfinal SrndQueryfinal SrndQueryvoidReInit(CharStream stream) Reinitialise.voidReinitialise.final SrndQueryfinal SrndQueryfinal booleanTrace enabled.final SrndQueryWQuery()
-
Field Details
-
token_source
Generated Token Manager. -
token
Current token. -
jj_nt
Next token.
-
-
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
-
ReInit
Reinitialise. -
ReInit
Reinitialise. -
getNextToken
Get the next Token. -
getToken
Get the specific Token. -
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.
-