public class QueryParser extends Object implements 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.
Modifier and Type | Field and Description |
---|---|
Token |
jj_nt
Next token.
|
Token |
token
Current token.
|
QueryParserTokenManager |
token_source
Generated Token Manager.
|
_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 and Description |
---|
QueryParser() |
QueryParser(CharStream stream)
Constructor with user supplied CharStream.
|
QueryParser(QueryParserTokenManager tm)
Constructor with generated Token Manager.
|
public QueryParserTokenManager token_source
public Token token
public Token jj_nt
public QueryParser()
public QueryParser(CharStream stream)
public QueryParser(QueryParserTokenManager tm)
public static SrndQuery parse(String query) throws ParseException
ParseException
public SrndQuery parse2(String query) throws ParseException
ParseException
protected static int getOpDistance(String distanceOp)
protected static void checkDistanceSubQueries(DistanceQuery distq, String opName) throws ParseException
ParseException
protected SrndQuery getDistanceQuery(List<SrndQuery> queries, boolean infix, Token dToken, boolean ordered) throws ParseException
ParseException
protected boolean allowedSuffix(String suffixed)
protected boolean allowedTruncation(String truncated)
public final SrndQuery TopSrndQuery() throws ParseException
ParseException
public final SrndQuery FieldsQuery() throws ParseException
ParseException
public final ArrayList<String> OptionalFields() throws ParseException
ParseException
public final SrndQuery OrQuery() throws ParseException
ParseException
public final SrndQuery AndQuery() throws ParseException
ParseException
public final SrndQuery NotQuery() throws ParseException
ParseException
public final SrndQuery NQuery() throws ParseException
ParseException
public final SrndQuery WQuery() throws ParseException
ParseException
public final SrndQuery PrimaryQuery() throws ParseException
ParseException
public final SrndQuery PrefixOperatorQuery() throws ParseException
ParseException
public final List<SrndQuery> FieldsQueryList() throws ParseException
ParseException
public final SrndQuery SimpleTerm() throws ParseException
ParseException
public final void OptionalWeights(SrndQuery q) throws ParseException
ParseException
public void ReInit(CharStream stream)
public void ReInit(QueryParserTokenManager tm)
public final Token getNextToken()
public final Token getToken(int index)
public ParseException generateParseException()
public final void enable_tracing()
public final void disable_tracing()
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.