C# Class Lucene.Net.QueryParsers.Classic.QueryParser

This class is generated by JavaCC. The most important method is QueryParserBase.Parse(string). 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 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 ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )

Examples of appropriately formatted queries can be found in the query syntax documentation.

In TermRangeQuerys, QueryParser tries to detect date values, e.g. date:[6/1/2005 TO 6/4/2005] produces a range query that searches for "date" fields between 2005-06-01 and 2005-06-04. Note that the format of the accepted input depends on the Locale. A Documents.DateTools.Resolution has to be set, if you want to use Documents.DateTools for date conversion.

The date resolution that shall be used for RangeQueries can be set using QueryParserBase.SetDateResolution(Documents.DateTools.Resolution) or QueryParserBase.SetDateResolution(string, Documents.DateTools.Resolution). The former sets the default date resolution for all fields, whereas the latter can be used to set field specific date resolutions. Field specific date resolutions take, if set, precedence over the default date resolution.

If you don't use Documents.DateTools in your index, you can create your own query parser that inherits QueryParser and overwrites QueryParserBase.GetRangeQuery(string, string, string, bool, bool) to use a different method for date conversion.

Note that QueryParser is not thread-safe.

NOTE: there is a new QueryParser in contrib, which matches the same syntax as this class, but is more modular, enabling substantial customization to how a query is created.

NOTE: You must specify the required LuceneVersion compatibility when creating QueryParser: As of 3.1, QueryParserBase.AutoGeneratePhraseQueries is false by default.
Inheritance: Lucene.Net.QueryParsers.Classic.QueryParserBase
Afficher le fichier Open project: apache/lucenenet Class Usage Examples

Méthodes publiques

Свойство Type Description
jj_nt Token
token Token
token_source QueryParserTokenManager

Méthodes publiques

Méthode Description
Clause ( string field ) : Query
Conjunction ( ) : int
Disable_tracing ( ) : void

Disable tracing.

Enable_tracing ( ) : void

Enable tracing.

GenerateParseException ( ) : ParseException

Generate ParseException.

GetNextToken ( ) : Token

Get the next Token.

GetToken ( int index ) : Token

Get the specific Token.

Modifiers ( ) : int
Query ( string field ) : Query
QueryParser ( LuceneVersion matchVersion, string f, Analyzer a ) : Lucene.Net.Analysis

Constructs a query parser.

ReInit ( ICharStream stream ) : void

Reinitialize.

ReInit ( QueryParserTokenManager tm ) : void

Reinitialize.

Term ( string field ) : Query
TopLevelQuery ( string field ) : Query

Méthodes protégées

Méthode Description
QueryParser ( ICharStream stream ) : Lucene.Net.Analysis

Constructor with user supplied ICharStream.

QueryParser ( QueryParserTokenManager tm ) : Lucene.Net.Analysis

Constructor with generated Token Manager.

Private Methods

Méthode Description
Jj_2_1 ( int xla ) : bool
Jj_3R_2 ( ) : bool
Jj_3R_3 ( ) : bool
Jj_3_1 ( ) : bool
Jj_add_error_token ( int kind, int pos ) : void
Jj_consume_token ( int kind ) : Token
Jj_la1_init_0 ( ) : void
Jj_la1_init_1 ( ) : void
Jj_ntk ( ) : int
Jj_rescan_token ( ) : void
Jj_save ( int index, int xla ) : void
Jj_scan_token ( int kind ) : bool
QueryParser ( ) : Lucene.Net.Analysis

Method Details

Clause() public méthode

public Clause ( string field ) : Query
field string
Résultat Lucene.Net.Search.Query

Conjunction() public méthode

public Conjunction ( ) : int
Résultat int

Disable_tracing() public méthode

Disable tracing.
public Disable_tracing ( ) : void
Résultat void

Enable_tracing() public méthode

Enable tracing.
public Enable_tracing ( ) : void
Résultat void

GenerateParseException() public méthode

Generate ParseException.
public GenerateParseException ( ) : ParseException
Résultat ParseException

GetNextToken() public méthode

Get the next Token.
public GetNextToken ( ) : Token
Résultat Token

GetToken() public méthode

Get the specific Token.
public GetToken ( int index ) : Token
index int
Résultat Token

Modifiers() public méthode

public Modifiers ( ) : int
Résultat int

Query() public méthode

public Query ( string field ) : Query
field string
Résultat Lucene.Net.Search.Query

QueryParser() protected méthode

Constructor with user supplied ICharStream.
protected QueryParser ( ICharStream stream ) : Lucene.Net.Analysis
stream ICharStream
Résultat Lucene.Net.Analysis

QueryParser() public méthode

Constructs a query parser.
public QueryParser ( LuceneVersion matchVersion, string f, Analyzer a ) : Lucene.Net.Analysis
matchVersion LuceneVersion Lucene version to match.
f string the default field for query terms.
a Lucene.Net.Analysis.Analyzer used to find terms in the query text.
Résultat Lucene.Net.Analysis

QueryParser() protected méthode

Constructor with generated Token Manager.
protected QueryParser ( QueryParserTokenManager tm ) : Lucene.Net.Analysis
tm QueryParserTokenManager
Résultat Lucene.Net.Analysis

ReInit() public méthode

Reinitialize.
public ReInit ( ICharStream stream ) : void
stream ICharStream
Résultat void

ReInit() public méthode

Reinitialize.
public ReInit ( QueryParserTokenManager tm ) : void
tm QueryParserTokenManager
Résultat void

Term() public méthode

public Term ( string field ) : Query
field string
Résultat Lucene.Net.Search.Query

TopLevelQuery() public final méthode

public final TopLevelQuery ( string field ) : Query
field string
Résultat Lucene.Net.Search.Query

Property Details

jj_nt public_oe property

Next token.
public Token jj_nt
Résultat Token

token public_oe property

Current token.
public Token token
Résultat Token

token_source public_oe property

Generated Token Manager.
public QueryParserTokenManager,Lucene.Net.QueryParsers.Classic token_source
Résultat QueryParserTokenManager