C# Класс Lucene.Net.QueryParsers.QueryParser

This class is generated by JavaCC. The most important method is {@link #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 {@link RangeQuery}s, 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 {@link #SetLocale(Locale) the locale}. By default a date is converted into a search term using the deprecated {@link DateField} for compatibility reasons. To use the new {@link DateTools} to convert dates, a {@link Lucene.Net.Documents.DateTools.Resolution} has to be set.

The date resolution that shall be used for RangeQueries can be set using {@link #SetDateResolution(DateTools.Resolution)} or {@link #SetDateResolution(String, 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 use neither {@link DateField} nor {@link DateTools} in your index, you can create your own query parser that inherits QueryParser and overwrites {@link #GetRangeQuery(String, String, String, boolean)} to use a different method for date conversion.

Note that QueryParser is not thread-safe.

Наследование: Lucene.Net.QueryParsers.QueryParserConstants
Показать файл Открыть проект Примеры использования класса

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

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

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

Метод Описание
Clause ( String field ) : Query
Conjunction ( ) : int
Disable_tracing ( ) : void

Disable tracing.

Enable_tracing ( ) : void

Enable tracing.

Escape ( String s ) : String

Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding \.

GenerateParseException ( ) : Lucene.Net.QueryParsers.ParseException

Generate ParseException.

GetNextToken ( ) : Token

Get the next Token.

Modifiers ( ) : int
Parse ( String query ) : Query

Parses a query string, returning a {@link Lucene.Net.Search.Query}.

Query ( String field ) : Query
QueryParser ( Lucene.Net.Util.Version matchVersion, String f, Analyzer a ) : System
ReInit ( ICharStream stream ) : void

Reinitialise.

ReInit ( Lucene.Net.QueryParsers.QueryParserTokenManager tm ) : void

Reinitialise.

SetDateResolution ( Lucene.Net.Documents.DateTools dateResolution ) : void

Sets the default date resolution used by RangeQueries for fields for which no specific date resolutions has been set. Field specific resolutions can be set with {@link #SetDateResolution(String, DateTools.Resolution)}.

SetDateResolution ( String fieldName, Lucene.Net.Documents.DateTools dateResolution ) : void

Sets the date resolution used by RangeQueries for a specific field.

Term ( String field ) : Query
TopLevelQuery ( String field ) : Query
getDateResolution ( String fieldName ) : Lucene.Net.Documents.DateTools.Resolution

Returns the date resolution that is used by RangeQueries for the given field. Returns null, if no default or field specific date resolution has been set for the given field.

getToken ( int index ) : Token

Get the specific Token.

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

Метод Описание
AddClause ( List clauses, int conj, int mods, Query q ) : void
GetBooleanQuery ( IList clauses ) : Query

Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in. Can be overridden by extending classes, to modify query being returned.

GetBooleanQuery ( IList clauses, bool disableCoord ) : Query

Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in. Can be overridden by extending classes, to modify query being returned.

GetFieldQuery ( String field, String queryText ) : Query
GetFieldQuery ( String field, String queryText, int slop ) : Query

Base implementation delegates to {@link #GetFieldQuery(String,String)}. This method may be overridden, for example, to return a SpanNearQuery instead of a PhraseQuery.

GetFuzzyQuery ( String field, String termStr, float minSimilarity ) : Query

Factory method for generating a query (similar to {@link #getWildcardQuery}). Called when parser parses an input term token that has the fuzzy suffix (~) appended.

GetPrefixQuery ( String field, String termStr ) : Query

Factory method for generating a query (similar to {@link #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.

Depending on settings, a prefix term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with wildcard templates.

Can be overridden by extending classes, to provide custom handling for wild card queries, which may be necessary due to missing analyzer calls.

GetRangeQuery ( String field, String part1, String part2, bool inclusive ) : Query
GetWildcardQuery ( String field, String termStr ) : Query

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)

Depending on settings, prefix term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with wildcard templates.

Can be overridden by extending classes, to provide custom handling for wildcard queries, which may be necessary due to missing analyzer calls.

NewBooleanClause ( Query q, Occur occur ) : BooleanClause

Builds a new BooleanClause instance

NewBooleanQuery ( bool disableCoord ) : Lucene.Net.Search.BooleanQuery

Builds a new BooleanQuery instance

NewFuzzyQuery ( Lucene.Net.Index.Term term, float minimumSimilarity, int prefixLength ) : Query

Builds a new FuzzyQuery instance

NewMatchAllDocsQuery ( ) : Query

Builds a new MatchAllDocsQuery instance

NewMultiPhraseQuery ( ) : MultiPhraseQuery

Builds a new MultiPhraseQuery instance

NewPhraseQuery ( ) : PhraseQuery

Builds a new PhraseQuery instance

NewPrefixQuery ( Lucene.Net.Index.Term prefix ) : Query

Builds a new PrefixQuery instance

NewRangeQuery ( String field, String part1, String part2, bool inclusive ) : Query

Builds a new TermRangeQuery instance

NewTermQuery ( Lucene.Net.Index.Term term ) : Query

Builds a new TermQuery instance

NewWildcardQuery ( Lucene.Net.Index.Term t ) : Query

Builds a new WildcardQuery instance

QueryParser ( ICharStream stream ) : System

Constructor with user supplied CharStream.

QueryParser ( Lucene.Net.QueryParsers.QueryParserTokenManager tm ) : System

Constructor with generated Token Manager.

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

Метод Описание
DiscardEscapeChar ( String input ) : String

Returns a String where the escape char has been removed, or kept only once if there was a double escape. Supports escaped unicode characters, e. g. translates \\u0041 to A.

HexToInt ( char c ) : int

Returns the numeric value of the hexadecimal character

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
Main ( String args ) : void
QueryParser ( ) : System
jj_scan_token ( int kind ) : bool

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

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

protected AddClause ( List clauses, int conj, int mods, Query q ) : void
clauses List
conj int
mods int
q Lucene.Net.Search.Query
Результат void

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

Escape() публичный статический Метод

Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding \.
public static Escape ( String s ) : String
s String
Результат String

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

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

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

Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in. Can be overridden by extending classes, to modify query being returned.
throw in overridden method to disallow ///
protected GetBooleanQuery ( IList clauses ) : Query
clauses IList List that contains {@link BooleanClause} instances /// to join. /// ///
Результат Lucene.Net.Search.Query

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

Factory method for generating query, given a set of clauses. By default creates a boolean query composed of clauses passed in. Can be overridden by extending classes, to modify query being returned.
throw in overridden method to disallow ///
protected GetBooleanQuery ( IList clauses, bool disableCoord ) : Query
clauses IList List that contains {@link BooleanClause} instances /// to join. ///
disableCoord bool true if coord scoring should be disabled. /// ///
Результат Lucene.Net.Search.Query

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

throw in overridden method to disallow ///
protected GetFieldQuery ( String field, String queryText ) : Query
field String
queryText String
Результат Lucene.Net.Search.Query

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

Base implementation delegates to {@link #GetFieldQuery(String,String)}. This method may be overridden, for example, to return a SpanNearQuery instead of a PhraseQuery.
throw in overridden method to disallow ///
protected GetFieldQuery ( String field, String queryText, int slop ) : Query
field String
queryText String
slop int
Результат Lucene.Net.Search.Query

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

Factory method for generating a query (similar to {@link #getWildcardQuery}). Called when parser parses an input term token that has the fuzzy suffix (~) appended.
throw in overridden method to disallow ///
protected GetFuzzyQuery ( String field, String termStr, float minSimilarity ) : Query
field String Name of the field query will use. ///
termStr String Term token to use for building term for the query /// ///
minSimilarity float
Результат Lucene.Net.Search.Query

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

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

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

Factory method for generating a query (similar to {@link #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.

Depending on settings, a prefix term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with wildcard templates.

Can be overridden by extending classes, to provide custom handling for wild card queries, which may be necessary due to missing analyzer calls.

throw in overridden method to disallow ///
protected GetPrefixQuery ( String field, String termStr ) : Query
field String Name of the field query will use. ///
termStr String Term token to use for building term for the query /// (without trailing '*' character!) /// ///
Результат Lucene.Net.Search.Query

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

throw in overridden method to disallow ///
protected GetRangeQuery ( String field, String part1, String part2, bool inclusive ) : Query
field String
part1 String
part2 String
inclusive bool
Результат Lucene.Net.Search.Query

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

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)

Depending on settings, prefix term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with wildcard templates.

Can be overridden by extending classes, to provide custom handling for wildcard queries, which may be necessary due to missing analyzer calls.

throw in overridden method to disallow ///
protected GetWildcardQuery ( String field, String termStr ) : Query
field String Name of the field query will use. ///
termStr String Term token that contains one or more wild card /// characters (? or *), but is not simple prefix term /// ///
Результат Lucene.Net.Search.Query

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

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

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

Builds a new BooleanClause instance
protected NewBooleanClause ( Query q, Occur occur ) : BooleanClause
q Lucene.Net.Search.Query sub query ///
occur Lucene.Net.Search.Occur how this clause should occur when matching documents ///
Результат Lucene.Net.Search.BooleanClause

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

Builds a new BooleanQuery instance
protected NewBooleanQuery ( bool disableCoord ) : Lucene.Net.Search.BooleanQuery
disableCoord bool disable coord ///
Результат Lucene.Net.Search.BooleanQuery

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

Builds a new FuzzyQuery instance
protected NewFuzzyQuery ( Lucene.Net.Index.Term term, float minimumSimilarity, int prefixLength ) : Query
term Lucene.Net.Index.Term Term ///
minimumSimilarity float minimum similarity ///
prefixLength int prefix length ///
Результат Lucene.Net.Search.Query

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

Builds a new MatchAllDocsQuery instance
protected NewMatchAllDocsQuery ( ) : Query
Результат Lucene.Net.Search.Query

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

Builds a new MultiPhraseQuery instance
protected NewMultiPhraseQuery ( ) : MultiPhraseQuery
Результат Lucene.Net.Search.MultiPhraseQuery

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

Builds a new PhraseQuery instance
protected NewPhraseQuery ( ) : PhraseQuery
Результат Lucene.Net.Search.PhraseQuery

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

Builds a new PrefixQuery instance
protected NewPrefixQuery ( Lucene.Net.Index.Term prefix ) : Query
prefix Lucene.Net.Index.Term Prefix term ///
Результат Lucene.Net.Search.Query

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

Builds a new TermRangeQuery instance
protected NewRangeQuery ( String field, String part1, String part2, bool inclusive ) : Query
field String Field ///
part1 String min ///
part2 String max ///
inclusive bool true if range is inclusive ///
Результат Lucene.Net.Search.Query

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

Builds a new TermQuery instance
protected NewTermQuery ( Lucene.Net.Index.Term term ) : Query
term Lucene.Net.Index.Term term ///
Результат Lucene.Net.Search.Query

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

Builds a new WildcardQuery instance
protected NewWildcardQuery ( Lucene.Net.Index.Term t ) : Query
t Lucene.Net.Index.Term wildcard term ///
Результат Lucene.Net.Search.Query

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

Parses a query string, returning a {@link Lucene.Net.Search.Query}.
public Parse ( String query ) : Query
query String the query string to be parsed. ///
Результат Lucene.Net.Search.Query

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

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

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

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

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

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

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

public QueryParser ( Lucene.Net.Util.Version matchVersion, String f, Analyzer a ) : System
matchVersion Lucene.Net.Util.Version
f String
a Lucene.Net.Analysis.Analyzer
Результат System

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

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

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

Reinitialise.
public ReInit ( Lucene.Net.QueryParsers.QueryParserTokenManager tm ) : void
tm Lucene.Net.QueryParsers.QueryParserTokenManager
Результат void

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

Sets the default date resolution used by RangeQueries for fields for which no specific date resolutions has been set. Field specific resolutions can be set with {@link #SetDateResolution(String, DateTools.Resolution)}.
public SetDateResolution ( Lucene.Net.Documents.DateTools dateResolution ) : void
dateResolution Lucene.Net.Documents.DateTools the default date resolution to set ///
Результат void

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

Sets the date resolution used by RangeQueries for a specific field.
public SetDateResolution ( String fieldName, Lucene.Net.Documents.DateTools dateResolution ) : void
fieldName String field for which the date resolution is to be set ///
dateResolution Lucene.Net.Documents.DateTools date resolution to set ///
Результат void

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

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

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

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

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

Returns the date resolution that is used by RangeQueries for the given field. Returns null, if no default or field specific date resolution has been set for the given field.
public getDateResolution ( String fieldName ) : Lucene.Net.Documents.DateTools.Resolution
fieldName String
Результат Lucene.Net.Documents.DateTools.Resolution

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

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

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

AND_OPERATOR публичное статическое свойство

Alternative form of QueryParser.Operator.AND
public static Operator AND_OPERATOR
Результат Operator

OR_OPERATOR публичное статическое свойство

Alternative form of QueryParser.Operator.OR
public static Operator OR_OPERATOR
Результат Operator

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

public Token jj_nt
Результат Token

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

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

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

public QueryParserTokenManager token_source
Результат QueryParserTokenManager