org.apache.lucene.queryParser
Class QueryParser

java.lang.Object
  |
  +--org.apache.lucene.queryParser.QueryParser
All Implemented Interfaces:
QueryParserConstants
Direct Known Subclasses:
MultiFieldQueryParser

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 clause may be either: Thus, in BNF, the query grammar is:
   Query  ::= ( Clause )*
   Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
 

Examples of appropriately formatted queries can be found in the test cases.

Author:
Brian Goetz

Field Summary
 Token jj_nt
           
 boolean lookingAhead
           
 Token token
           
 QueryParserTokenManager token_source
           
 
Fields inherited from interface org.apache.lucene.queryParser.QueryParserConstants
_ESCAPED_CHAR, _NUM_CHAR, _TERM_CHAR, _TERM_START_CHAR, _WHITESPACE, AND, Boost, CARAT, COLON, DEFAULT, EOF, FUZZY, LPAREN, MINUS, NOT, NUMBER, OR, PLUS, PREFIXTERM, QUOTED, RANGEEX, RANGEIN, RPAREN, SLOP, TERM, tokenImage, WILDTERM
 
Constructor Summary
QueryParser(CharStream stream)
           
QueryParser(QueryParserTokenManager tm)
           
QueryParser(String f, Analyzer a)
          Constructs a query parser.
 
Method Summary
 Query Clause(String field)
           
 int Conjunction()
           
 void disable_tracing()
           
 void enable_tracing()
           
 ParseException generateParseException()
           
 Token getNextToken()
           
 int getPhraseSlop()
          Gets the default slop for phrases.
 Token getToken(int index)
           
static void main(String[] args)
           
 int Modifiers()
           
 Query parse(String query)
          Parses a query string, returning a Query.
static Query parse(String query, String field, Analyzer analyzer)
          Parses a query string, returning a Query.
 Query Query(String field)
           
 void ReInit(CharStream stream)
           
 void ReInit(QueryParserTokenManager tm)
           
 void setPhraseSlop(int s)
          Sets the default slop for phrases.
 Query Term(String field)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public QueryParserTokenManager token_source

token

public Token token

jj_nt

public Token jj_nt

lookingAhead

public boolean lookingAhead
Constructor Detail

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(CharStream stream)

QueryParser

public QueryParser(QueryParserTokenManager tm)
Method Detail

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.
Throws:
ParseException - if the parsing fails

parse

public Query parse(String query)
            throws ParseException,
                   TokenMgrError
Parses a query string, returning a Query.
Parameters:
query - the query string to be parsed.
Throws:
ParseException - if the parsing fails
TokenMgrError - if ther parsing fails

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(CharStream 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()


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.