com.lucene.queryParser
Class QueryParser
java.lang.Object
|
+--com.lucene.queryParser.QueryParser
- All Implemented Interfaces:
- QueryParserConstants
- public class QueryParser
- extends Object
- implements QueryParserConstants
This class is generated by JavaCC. The only method that clients should need
to call is parse().
The syntax for query strings is as follows:
A Query is a series of clauses.
A clause may be prefixed by:
- a plus (
+
) or a minus (-
) sign, indicating
that the clause is required or prohibited respectively; or
- a term followed by a colon, indicating the field to be searched.
This enables one to construct queries which search multiple fields.
A clause may be either a:
- a term, indicating all the documents that contain this term; or
- a nested query, enclosed in parentheses. Note that this may be used
with a
+
/-
prefix to require any of a set of
terms.
Thus, in BNF, the query grammar is:
Query ::= ( Clause )*
Clause ::= ["+", "-"] [ ":"] ( | "(" Query ")" )
Fields inherited from interface com.lucene.queryParser.QueryParserConstants |
_ALPHA_CHAR, _ALPHANUM_CHAR, _IDENTIFIER, _IDENTIFIER_CHAR, _NEWLINE, _NUM_CHAR, _QCHAR, _RESTOFLINE, _WHITESPACE, AND, CARAT, COLON, DEFAULT, EOF, LPAREN, MINUS, NOT, NUMBER, OR, PLUS, QUOTED, RPAREN, STAR, TERM, tokenImage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
token_source
public QueryParserTokenManager token_source
token
public Token token
jj_nt
public Token jj_nt
lookingAhead
public boolean lookingAhead
QueryParser
public QueryParser(String f,
Analyzer a)
- Constructs a query parser.
- Parameters:
field
- the default field for query terms.analyzer
- used to find terms in the query text.
QueryParser
public QueryParser(InputStream stream)
QueryParser
public QueryParser(Reader stream)
QueryParser
public QueryParser(QueryParserTokenManager tm)
parse
public static Query parse(String query,
String field,
Analyzer analyzer)
throws ParseException
- Parses a query string, returning a
Query.
- Parameters:
query
- the query string to be parsed.field
- the default field for query terms.analyzer
- used to find terms in the query text.
parse
public Query parse(String query)
throws ParseException
- Parses a query string, returning a
Query.
- Parameters:
query
- the query string to be parsed.
setPhraseSlop
public void setPhraseSlop(int s)
- Sets the default slop for phrases. If zero, then exact phrase matches
are required. Zero by default.
getPhraseSlop
public int getPhraseSlop()
- Gets the default slop for phrases.
main
public static void main(String[] args)
throws Exception
Conjunction
public final int Conjunction()
throws ParseException
Modifiers
public final int Modifiers()
throws ParseException
Query
public final Query Query(String field)
throws ParseException
Clause
public final Query Clause(String field)
throws ParseException
Term
public final Query Term(String field)
throws ParseException
ReInit
public void ReInit(InputStream stream)
ReInit
public void ReInit(Reader stream)
ReInit
public void ReInit(QueryParserTokenManager tm)
getNextToken
public final Token getNextToken()
getToken
public final Token getToken(int index)
generateParseException
public final ParseException generateParseException()
enable_tracing
public final void enable_tracing()
disable_tracing
public final void disable_tracing()