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
파일 보기 프로젝트 열기: synhershko/lucene.net 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
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