Lucene.Net
3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
|
This class is generated by JavaCC. The most important method is Parse(String). More...
Inherits Lucene.Net.QueryParsers.QueryParserConstants.
Inherited by Lucene.Net.QueryParsers.MultiFieldQueryParser.
Classes | |
class | JJCalls |
Public Types | |
enum | Operator { OR, AND } |
Public Member Functions | |
QueryParser (Version matchVersion, String f, Analyzer a) | |
virtual Query | Parse (String query) |
Parses a query string, returning a Lucene.Net.Search.Query. | |
virtual void | SetDateResolution (DateTools.Resolution dateResolution) |
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 SetDateResolution(String, DateTools.Resolution). | |
virtual void | SetDateResolution (String fieldName, DateTools.Resolution dateResolution) |
Sets the date resolution used by RangeQueries for a specific field. | |
virtual DateTools.Resolution | getDateResolution (String fieldName) |
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. | |
int | Conjunction () |
int | Modifiers () |
Query | TopLevelQuery (String field) |
Query | Query (String field) |
Query | Clause (String field) |
Query | Term (String field) |
void | ReInit (ICharStream stream) |
Reinitialise. | |
void | ReInit (QueryParserTokenManager tm) |
Reinitialise. | |
Token | GetNextToken () |
Get the next Token. | |
Token | getToken (int index) |
Get the specific Token. | |
virtual ParseException | GenerateParseException () |
Generate ParseException. | |
void | Enable_tracing () |
Enable tracing. | |
void | Disable_tracing () |
Disable tracing. | |
Static Public Member Functions | |
static String | Escape (String s) |
Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding </c>. | |
static void | Main (String[] args) |
Command line tool to test QueryParser, using Lucene.Net.Analysis.SimpleAnalyzer. Usage:java Lucene.Net.QueryParsers.QueryParser <input> | |
Public Attributes | |
QueryParserTokenManager | token_source |
Token | token |
Token | jj_nt |
Static Public Attributes | |
static Operator | AND_OPERATOR = Operator.AND |
Alternative form of QueryParser.Operator.AND | |
static Operator | OR_OPERATOR = Operator.OR |
Alternative form of QueryParser.Operator.OR | |
Protected Member Functions | |
QueryParser (QueryParserTokenManager tm) | |
Constructor with generated Token Manager. | |
Properties | |
virtual Analyzer | Analyzer [get] |
Returns the analyzer. | |
virtual string | Field [get] |
Returns the field. | |
virtual float | FuzzyMinSim [get, set] |
Gets or sets the minimal similarity for fuzzy queries. Default is 0.5f. | |
virtual int | FuzzyPrefixLength [get, set] |
Gets or sets the prefix length for fuzzy queries. | |
virtual int | PhraseSlop [get, set] |
Gets or sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero. | |
virtual bool | AllowLeadingWildcard [get, set] |
Set to true to allow leading wildcard characters. When set, * or ? are allowed as the first character of a PrefixQuery and WildcardQuery. Note that this can produce very slow queries on big indexes. Default: false. | |
virtual bool | EnablePositionIncrements [get, set] |
Set to true to enable position increments in result query. When set, result phrase and multi-phrase queries will be aware of position increments. Useful when e.g. a StopFilter increases the position increment of the token that follows an omitted token. Default: false. | |
virtual Operator | DefaultOperator [get, set] |
Gets or sets the boolean operator of the QueryParser. In default mode (OR_OPERATOR ) terms without any modifiers are considered optional: for example capital of Hungary is equal to capital OR of OR Hungary .In AND_OPERATOR mode terms are considered to be in conjunction: the above mentioned query is parsed as capital AND of AND Hungary | |
virtual bool | LowercaseExpandedTerms [get, set] |
Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. Default is true . | |
virtual RewriteMethod | MultiTermRewriteMethod [get, set] |
By default QueryParser uses MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT when creating a PrefixQuery, WildcardQuery or RangeQuery. This implementation is generally preferable because it a) Runs faster b) Does not have the scarcity of terms unduly influence score c) avoids any "TooManyBooleanClauses" exception. However, if your application really needs to use the old-fashioned BooleanQuery expansion rewriting and the above points are not relevant then use this to change the rewrite method. | |
virtual CultureInfo | Locale [get, set] |
Gets or sets locale used by date range parsing. | |
virtual CompareInfo | RangeCollator [get, set] |
Gets or sets the collator used to determine index term inclusion in ranges for RangeQuerys. WARNING: Setting the rangeCollator to a non-null collator using this method will cause every single index Term in the Field referenced by lowerTerm and/or upperTerm to be examined. Depending on the number of index Terms in this Field, the operation could be very slow. | |
Additional Inherited Members | |
Protected Attributes inherited from Lucene.Net.QueryParsers.QueryParserConstants | |
const int | RangeExToken = 1 |
Lexical state. | |
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:
+
) or a minus (-
) sign, indicating that the clause is required or prohibited respectively; or A clause may be either:
+
/-
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. By default a date is converted into a search term using the deprecated DateField for compatibility reasons. To use the new DateTools to convert dates, a Lucene.Net.Documents.DateTools.Resolution has to be set.
The date resolution that shall be used for RangeQueries can be set using SetDateResolution(DateTools.Resolution) or 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 DateField nor DateTools in your index, you can create your own query parser that inherits QueryParser and overwrites GetRangeQuery(String, String, String, 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: 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 Version compatibility when creating QueryParser:
Definition at line 130 of file QueryParser.cs.
enum Lucene.Net.QueryParsers.QueryParser.Operator |
Enumerator | |
---|---|
OR | |
AND |
Definition at line 180 of file QueryParser.cs.
Definition at line 192 of file QueryParser.cs.
|
protected |
Constructor with generated Token Manager.
Definition at line 1814 of file QueryParser.cs.
Query Lucene.Net.QueryParsers.QueryParser.Clause | ( | String | field | ) |
Definition at line 1345 of file QueryParser.cs.
int Lucene.Net.QueryParsers.QueryParser.Conjunction | ( | ) |
Definition at line 1212 of file QueryParser.cs.
void Lucene.Net.QueryParsers.QueryParser.Disable_tracing | ( | ) |
Disable tracing.
Definition at line 2027 of file QueryParser.cs.
void Lucene.Net.QueryParsers.QueryParser.Enable_tracing | ( | ) |
Enable tracing.
Definition at line 2022 of file QueryParser.cs.
|
static |
Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding </c>.
Definition at line 1175 of file QueryParser.cs.
|
virtual |
Generate ParseException.
Definition at line 1975 of file QueryParser.cs.
|
virtual |
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.
Definition at line 394 of file QueryParser.cs.
Token Lucene.Net.QueryParsers.QueryParser.GetNextToken | ( | ) |
Get the next Token.
Definition at line 1905 of file QueryParser.cs.
Token Lucene.Net.QueryParsers.QueryParser.getToken | ( | int | index | ) |
Get the specific Token.
Definition at line 1915 of file QueryParser.cs.
|
static |
Command line tool to test QueryParser, using Lucene.Net.Analysis.SimpleAnalyzer. Usage:
java Lucene.Net.QueryParsers.QueryParser <input>
Definition at line 1198 of file QueryParser.cs.
int Lucene.Net.QueryParsers.QueryParser.Modifiers | ( | ) |
Definition at line 1245 of file QueryParser.cs.
|
virtual |
Parses a query string, returning a Lucene.Net.Search.Query.
query | the query string to be parsed. |
<throws> ParseException if the parsing fails </throws>
Definition at line 217 of file QueryParser.cs.
Query Lucene.Net.QueryParsers.QueryParser.Query | ( | String | field | ) |
Definition at line 1295 of file QueryParser.cs.
void Lucene.Net.QueryParsers.QueryParser.ReInit | ( | ICharStream | stream | ) |
Reinitialise.
Definition at line 1803 of file QueryParser.cs.
void Lucene.Net.QueryParsers.QueryParser.ReInit | ( | QueryParserTokenManager | tm | ) |
Reinitialise.
Definition at line 1825 of file QueryParser.cs.
|
virtual |
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 SetDateResolution(String, DateTools.Resolution).
dateResolution | the default date resolution to set |
Definition at line 362 of file QueryParser.cs.
|
virtual |
Sets the date resolution used by RangeQueries for a specific field.
fieldName | field for which the date resolution is to be set |
dateResolution | date resolution to set |
Definition at line 374 of file QueryParser.cs.
Query Lucene.Net.QueryParsers.QueryParser.Term | ( | String | field | ) |
Definition at line 1422 of file QueryParser.cs.
Query Lucene.Net.QueryParsers.QueryParser.TopLevelQuery | ( | String | field | ) |
Definition at line 1284 of file QueryParser.cs.
|
static |
Alternative form of QueryParser.Operator.AND
Definition at line 144 of file QueryParser.cs.
Token Lucene.Net.QueryParsers.QueryParser.jj_nt |
Definition at line 1759 of file QueryParser.cs.
|
static |
Alternative form of QueryParser.Operator.OR
Definition at line 147 of file QueryParser.cs.
Token Lucene.Net.QueryParsers.QueryParser.token |
Definition at line 1757 of file QueryParser.cs.
QueryParserTokenManager Lucene.Net.QueryParsers.QueryParser.token_source |
Definition at line 1755 of file QueryParser.cs.
|
getset |
Set to true
to allow leading wildcard characters. When set, *
or ?
are allowed as the first character of a PrefixQuery and WildcardQuery. Note that this can produce very slow queries on big indexes. Default: false.
Definition at line 290 of file QueryParser.cs.
|
get |
Returns the analyzer.
Definition at line 243 of file QueryParser.cs.
|
getset |
Gets or sets the boolean operator of the QueryParser. In default mode (OR_OPERATOR
) terms without any modifiers are considered optional: for example capital of Hungary
is equal to capital OR of OR Hungary
.
In AND_OPERATOR
mode terms are considered to be in conjunction: the above mentioned query is parsed as capital AND of AND Hungary
Definition at line 318 of file QueryParser.cs.
|
getset |
Set to true
to enable position increments in result query. When set, result phrase and multi-phrase queries will be aware of position increments. Useful when e.g. a StopFilter increases the position increment of the token that follows an omitted token. Default: false.
Definition at line 305 of file QueryParser.cs.
|
get |
Returns the field.
Definition at line 249 of file QueryParser.cs.
|
getset |
Gets or sets the minimal similarity for fuzzy queries. Default is 0.5f.
Definition at line 258 of file QueryParser.cs.
|
getset |
Gets or sets the prefix length for fuzzy queries.
Returns the fuzzyPrefixLength.
Definition at line 266 of file QueryParser.cs.
|
getset |
Gets or sets locale used by date range parsing.
Definition at line 350 of file QueryParser.cs.
|
getset |
Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. Default is true
.
Definition at line 327 of file QueryParser.cs.
|
getset |
By default QueryParser uses MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT when creating a PrefixQuery, WildcardQuery or RangeQuery. This implementation is generally preferable because it a) Runs faster b) Does not have the scarcity of terms unduly influence score c) avoids any "TooManyBooleanClauses" exception. However, if your application really needs to use the old-fashioned BooleanQuery expansion rewriting and the above points are not relevant then use this to change the rewrite method.
Definition at line 343 of file QueryParser.cs.
|
getset |
Gets or sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero.
Definition at line 275 of file QueryParser.cs.
|
getset |
Gets or sets the collator used to determine index term inclusion in ranges for RangeQuerys. WARNING: Setting the rangeCollator to a non-null collator using this method will cause every single index Term in the Field referenced by lowerTerm and/or upperTerm to be examined. Depending on the number of index Terms in this Field, the operation could be very slow.
the collator to use when constructing RangeQuerys
Definition at line 429 of file QueryParser.cs.