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
Modifier 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
ConstructorDescriptionQueryParser
(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) 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
-
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.
-