C# Класс 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.
Наследование: Lucene.Net.QueryParsers.Classic.QueryParserBase
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
jj_nt Token
token Token
token_source QueryParserTokenManager

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
QueryParser ( ICharStream stream ) : Lucene.Net.Analysis

Constructor with user supplied ICharStream.

QueryParser ( QueryParserTokenManager tm ) : Lucene.Net.Analysis

Constructor with generated Token Manager.

Приватные методы

Метод Описание
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

Описание методов

Clause() публичный Метод

public Clause ( string field ) : Query
field string
Результат Lucene.Net.Search.Query

Conjunction() публичный Метод

public Conjunction ( ) : int
Результат int

Disable_tracing() публичный Метод

Disable tracing.
public Disable_tracing ( ) : void
Результат void

Enable_tracing() публичный Метод

Enable tracing.
public Enable_tracing ( ) : void
Результат void

GenerateParseException() публичный Метод

Generate ParseException.
public GenerateParseException ( ) : ParseException
Результат ParseException

GetNextToken() публичный Метод

Get the next Token.
public GetNextToken ( ) : Token
Результат Token

GetToken() публичный Метод

Get the specific Token.
public GetToken ( int index ) : Token
index int
Результат Token

Modifiers() публичный Метод

public Modifiers ( ) : int
Результат int

Query() публичный Метод

public Query ( string field ) : Query
field string
Результат Lucene.Net.Search.Query

QueryParser() защищенный Метод

Constructor with user supplied ICharStream.
protected QueryParser ( ICharStream stream ) : Lucene.Net.Analysis
stream ICharStream
Результат Lucene.Net.Analysis

QueryParser() публичный Метод

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.
Результат Lucene.Net.Analysis

QueryParser() защищенный Метод

Constructor with generated Token Manager.
protected QueryParser ( QueryParserTokenManager tm ) : Lucene.Net.Analysis
tm QueryParserTokenManager
Результат Lucene.Net.Analysis

ReInit() публичный Метод

Reinitialize.
public ReInit ( ICharStream stream ) : void
stream ICharStream
Результат void

ReInit() публичный Метод

Reinitialize.
public ReInit ( QueryParserTokenManager tm ) : void
tm QueryParserTokenManager
Результат void

Term() публичный Метод

public Term ( string field ) : Query
field string
Результат Lucene.Net.Search.Query

TopLevelQuery() публичный закрытый Метод

public final TopLevelQuery ( string field ) : Query
field string
Результат Lucene.Net.Search.Query

Описание свойств

jj_nt публичное свойство

Next token.
public Token jj_nt
Результат Token

token публичное свойство

Current token.
public Token token
Результат Token

token_source публичное свойство

Generated Token Manager.
public QueryParserTokenManager,Lucene.Net.QueryParsers.Classic token_source
Результат QueryParserTokenManager