Logo Search packages:      
Sourcecode: beagle version File versions  Download package

Lucene::Net::QueryParsers::QueryParser Class Reference

Inheritance diagram for Lucene::Net::QueryParsers::QueryParser:

Lucene::Net::QueryParsers::MultiFieldQueryParser

List of all members.


Detailed Description

This class is generated by JavaCC. The most important method is Parse(String).

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 query syntax documentation.

Note that QueryParser is not thread-safe.

<author> Brian Goetz </author> <author> Peter Halacsy </author> <author> Tatu Saloranta </author>

Definition at line 73 of file QueryParser.cs.


Public Member Functions

Query Clause (System.String field)
int Conjunction ()
void Disable_tracing ()
void Enable_tracing ()
virtual ParseException GenerateParseException ()
virtual Analyzer GetAnalyzer ()
virtual Operator GetDefaultOperator ()
 Gets implicit operator setting, which will be either AND_OPERATOR or OR_OPERATOR.
virtual System.String GetField ()
virtual float GetFuzzyMinSim ()
 Get the minimal similarity for fuzzy queries.
virtual int GetFuzzyPrefixLength ()
 Get the prefix length for fuzzy queries.
virtual
System.Globalization.CultureInfo 
GetLocale ()
 Returns current locale, allowing access by subclasses.
virtual bool GetLowercaseExpandedTerms ()
virtual bool GetLowercaseWildcardTerms ()
Token GetNextToken ()
virtual int GetOperator ()
 Gets implicit operator setting, which will be either DEFAULT_OPERATOR_AND or DEFAULT_OPERATOR_OR.
virtual int GetPhraseSlop ()
 Gets the default slop for phrases.
Token GetToken (int index)
int Modifiers ()
virtual Query Parse (System.String query)
 Parses a query string, returning a Lucene.Net.search.Query.
Query Query (System.String field)
 QueryParser (QueryParserTokenManager tm)
 QueryParser (CharStream stream)
 QueryParser (System.String f, Analyzer a)
 Constructs a query parser.
virtual void ReInit (QueryParserTokenManager tm)
virtual void ReInit (CharStream stream)
virtual void SetDefaultOperator (Operator op)
 Sets the boolean operator of the QueryParser. In default mode () terms without any modifiers are considered optional: for example
capital of Hungary
is equal to
capital OR of OR Hungary
.
In mode terms are considered to be in conjuction: the above mentioned query is parsed as
capital AND of AND Hungary
.
virtual void SetFuzzyMinSim (float fuzzyMinSim)
 Set the minimum similarity for fuzzy queries. Default is 0.5f.
virtual void SetFuzzyPrefixLength (int fuzzyPrefixLength)
 Set the prefix length for fuzzy queries. Default is 0.
virtual void SetLocale (System.Globalization.CultureInfo locale)
 Set locale used by date range parsing.
virtual void SetLowercaseExpandedTerms (bool lowercaseExpandedTerms)
 Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. Default is
true
.
virtual void SetLowercaseWildcardTerms (bool lowercaseExpandedTerms)
 Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. Default is
true
.
virtual void SetOperator (int op)
 Sets the boolean operator of the QueryParser. In default mode () terms without any modifiers are considered optional: for example
capital of Hungary
is equal to
capital OR of OR Hungary
.
In terms are considered to be in conjuction: the above mentioned query is parsed as
capital AND of AND Hungary
.
virtual void SetPhraseSlop (int phraseSlop)
 Sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero.
Query Term (System.String field)

Static Public Member Functions

static System.String Escape (System.String s)
 Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding
\
.
static void Main (System.String[] args)
 Command line tool to test QueryParser, using Lucene.Net.analysis.SimpleAnalyzer. Usage:
java Lucene.Net.queryParser.QueryParser &lt;input&gt;
.
static Query Parse (System.String query, System.String field, Analyzer analyzer)
 Parses a query string, returning a Lucene.Net.search.Query.

Public Attributes

const int _ESCAPED_CHAR = 2
const int _NUM_CHAR = 1
const int _TERM_CHAR = 4
const int _TERM_START_CHAR = 3
const int _WHITESPACE = 5
const int AND = 7
const int Boost = 0
const int CARAT = 15
const int COLON = 14
const int DEFAULT = 3
const int DEFAULT_OPERATOR_AND = 1
const int DEFAULT_OPERATOR_OR = 0
const int EOF = 0
const int FUZZY_SLOP = 18
Token jj_nt
bool lookingAhead = false
const int LPAREN = 12
const int MINUS = 11
const int NOT = 9
const int NUMBER = 23
const int OR = 8
const int PLUS = 10
const int PREFIXTERM = 19
const int QUOTED = 16
const int RangeEx = 1
const int RANGEEX_END = 29
const int RANGEEX_GOOP = 31
const int RANGEEX_QUOTED = 30
const int RANGEEX_START = 22
const int RANGEEX_TO = 28
const int RangeIn = 2
const int RANGEIN_END = 25
const int RANGEIN_GOOP = 27
const int RANGEIN_QUOTED = 26
const int RANGEIN_START = 21
const int RANGEIN_TO = 24
const int RPAREN = 13
const int TERM = 17
Token token
QueryParserTokenManager token_source
const int WILDTERM = 20

Static Public Attributes

static readonly Operator AND_OPERATOR = Operator.AND
 Alternative form of QueryParser.Operator.AND.
static readonly Operator OR_OPERATOR = Operator.OR
 Alternative form of QueryParser.Operator.OR.
static System.String[] tokenImage = new System.String[]{"<EOF>", "<_NUM_CHAR>", "<_ESCAPED_CHAR>", "<_TERM_START_CHAR>", "<_TERM_CHAR>", "<_WHITESPACE>", "<token of kind 6>", "<AND>", "<OR>", "<NOT>", "\"+\"", "\"-\"", "\"(\"", "\")\"", "\":\"", "\"^\"", "<QUOTED>", "<TERM>", "<FUZZY_SLOP>", "<PREFIXTERM>", "<WILDTERM>", "\"[\"", "\"{\"", "<NUMBER>", "\"TO\"", "\"]\"", "<RANGEIN_QUOTED>", "<RANGEIN_GOOP>", "\"TO\"", "\"}\"", "<RANGEEX_QUOTED>", "<RANGEEX_GOOP>"}

Protected Member Functions

virtual internal void AddClause (System.Collections.ArrayList clauses, int conj, int mods, Query q)
virtual internal Query GetBooleanQuery (System.Collections.ArrayList clauses, bool disableCoord)
 Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in.
virtual internal Query GetBooleanQuery (System.Collections.ArrayList clauses)
 Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in.
virtual internal Query GetFieldQuery (System.String field, System.String queryText, int slop)
 Base implementation delegates to GetFieldQuery(String,String). This method may be overridden, for example, to return a SpanNearQuery instead of a PhraseQuery.
virtual internal Query GetFieldQuery (System.String field, Analyzer analyzer, System.String queryText, int slop)
 Note that parameter analyzer is ignored. Calls inside the parser always use class member analyzer.
virtual internal Query GetFieldQuery (System.String field, System.String queryText)
virtual internal Query GetFieldQuery (System.String field, Analyzer analyzer, System.String queryText)
 Note that parameter analyzer is ignored. Calls inside the parser always use class member analyzer.
virtual internal Query GetFuzzyQuery (System.String field, System.String termStr, float minSimilarity)
 Factory method for generating a query (similar to getWildcardQuery). Called when parser parses an input term token that has the fuzzy suffix (~) appended.
virtual internal Query GetFuzzyQuery (System.String field, System.String termStr)
virtual internal Query GetPrefixQuery (System.String field, System.String termStr)
 Factory method for generating a query (similar to getWildcardQuery). Called when parser parses an input term token that uses prefix notation; that is, contains a single '*' wildcard character as its last character. Since this is a special case of generic wildcard term, and such a query can be optimized easily, this usually results in a different query object.
virtual internal Query GetRangeQuery (System.String field, System.String part1, System.String part2, bool inclusive)
virtual internal Query GetRangeQuery (System.String field, Analyzer analyzer, System.String part1, System.String part2, bool inclusive)
 Note that parameter analyzer is ignored. Calls inside the parser always use class member analyzer.
virtual internal Query GetWildcardQuery (System.String field, System.String termStr)
 Factory method for generating a query. Called when parser parses an input term token that contains one or more wildcard characters (? and *), but is not a prefix term token (one that has just a single * character at the end).

Private Member Functions

System.String DiscardEscapeChar (System.String input)
 Returns a String where the escape char has been removed, or kept only once if there was a double escape.
void InitBlock ()
bool Jj_2_1 (int xla)
bool Jj_3_1 ()
void Jj_add_error_token (int kind, int pos)
Token Jj_consume_token (int kind)
int Jj_ntk ()
void Jj_rescan_token ()
void Jj_save (int index, int xla)
bool Jj_scan_token (int kind)

Static Private Member Functions

static void Jj_la1_0 ()

Private Attributes

internal Analyzer analyzer
const int CONJ_AND = 1
const int CONJ_NONE = 0
const int CONJ_OR = 2
internal System.String field
internal float fuzzyMinSim
internal int fuzzyPrefixLength
JJCalls[] jj_2_rtns
int jj_endpos
System.Collections.ArrayList jj_expentries = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10))
int[] jj_expentry
int jj_gc = 0
int jj_gen
int jj_kind = - 1
int jj_la
int[] jj_la1 = new int[22]
Token jj_lastpos
int[] jj_lasttokens = new int[100]
LookaheadSuccess jj_ls
int jj_ntk
bool jj_rescan = false
Token jj_scanpos
bool jj_semLA
internal
System.Globalization.CultureInfo 
locale = System.Threading.Thread.CurrentThread.CurrentCulture
internal bool lowercaseExpandedTerms = true
const int MOD_NONE = 0
const int MOD_NOT = 10
const int MOD_REQ = 11
Operator operator_Renamed = OR_OPERATOR
 The actual operator that parser uses to combine query terms.
internal int phraseSlop = 0

Static Private Attributes

static uint[] jj_la1_0

Classes

class  JJCalls
class  LookaheadSuccess
class  Operator
 The default operator for parsing queries. Use QueryParser#setDefaultOperator to change it. More...

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index