Class QueryParser
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:- 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 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.
Query ::= ( Clause )*
Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
Examples of appropriately formatted queries can be found in the query syntax documentation.
In Lucene.Net.Search.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 CultureInfo. A Lucene.Net.Documents.DateResolution has to be set, if you want to use Lucene.Net.Documents.DateTools for date conversion.
The date resolution that shall be used for RangeQueries can be set using SetDateResolution(DateResolution) or SetDateResolution(string, DateResolution). 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 Lucene.Net.Documents.DateTools in your index, you can create your own query parser that inherits QueryParser and overwrites 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 Lucene.Net.Util.LuceneVersion compatibility when creating QueryParser:- As of 3.1, AutoGeneratePhraseQueries is false by default.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.QueryParsers.Classic
Assembly: Lucene.Net.QueryParser.dll
Syntax
public class QueryParser : QueryParserBase, ICommonQueryParserConfiguration
Constructors
QueryParser(ICharStream)
Constructor with user supplied ICharStream.
Declaration
protected QueryParser(ICharStream stream)
Parameters
Type | Name | Description |
---|---|---|
ICharStream | stream |
QueryParser(QueryParserTokenManager)
Constructor with generated Token Manager.
Declaration
protected QueryParser(QueryParserTokenManager tm)
Parameters
Type | Name | Description |
---|---|---|
QueryParserTokenManager | tm |
QueryParser(LuceneVersion, string, Analyzer)
Constructs a query parser.
Declaration
public QueryParser(LuceneVersion matchVersion, string f, Analyzer a)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | Lucene version to match. |
string | f | the default field for query terms. |
Analyzer | a | used to find terms in the query text. |
Properties
Jj_nt
Next token.
Declaration
public Token Jj_nt { get; set; }
Property Value
Type | Description |
---|---|
Token |
Token
Current token.
Declaration
public Token Token { get; set; }
Property Value
Type | Description |
---|---|
Token |
TokenSource
Generated Token Manager.
Declaration
public QueryParserTokenManager TokenSource { get; set; }
Property Value
Type | Description |
---|---|
QueryParserTokenManager |
Methods
Clause(string)
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:- 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 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.
Query ::= ( Clause )*
Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
Examples of appropriately formatted queries can be found in the query syntax documentation.
In Lucene.Net.Search.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 CultureInfo. A Lucene.Net.Documents.DateResolution has to be set, if you want to use Lucene.Net.Documents.DateTools for date conversion.
The date resolution that shall be used for RangeQueries can be set using SetDateResolution(DateResolution) or SetDateResolution(string, DateResolution). 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 Lucene.Net.Documents.DateTools in your index, you can create your own query parser that inherits QueryParser and overwrites 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 Lucene.Net.Util.LuceneVersion compatibility when creating QueryParser:- As of 3.1, AutoGeneratePhraseQueries is false by default.
Declaration
public Query Clause(string field)
Parameters
Type | Name | Description |
---|---|---|
string | field |
Returns
Type | Description |
---|---|
Query |
Conjunction()
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:- 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 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.
Query ::= ( Clause )*
Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
Examples of appropriately formatted queries can be found in the query syntax documentation.
In Lucene.Net.Search.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 CultureInfo. A Lucene.Net.Documents.DateResolution has to be set, if you want to use Lucene.Net.Documents.DateTools for date conversion.
The date resolution that shall be used for RangeQueries can be set using SetDateResolution(DateResolution) or SetDateResolution(string, DateResolution). 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 Lucene.Net.Documents.DateTools in your index, you can create your own query parser that inherits QueryParser and overwrites 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 Lucene.Net.Util.LuceneVersion compatibility when creating QueryParser:- As of 3.1, AutoGeneratePhraseQueries is false by default.
Declaration
public int Conjunction()
Returns
Type | Description |
---|---|
int |
Disable_tracing()
Disable tracing.
Declaration
public void Disable_tracing()
Enable_tracing()
Enable tracing.
Declaration
public void Enable_tracing()
GenerateParseException()
Generate ParseException.
Declaration
public virtual ParseException GenerateParseException()
Returns
Type | Description |
---|---|
ParseException |
GetNextToken()
Get the next Token.
Declaration
public Token GetNextToken()
Returns
Type | Description |
---|---|
Token |
GetToken(int)
Get the specific Token.
Declaration
public Token GetToken(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index |
Returns
Type | Description |
---|---|
Token |
Modifiers()
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:- 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 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.
Query ::= ( Clause )*
Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
Examples of appropriately formatted queries can be found in the query syntax documentation.
In Lucene.Net.Search.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 CultureInfo. A Lucene.Net.Documents.DateResolution has to be set, if you want to use Lucene.Net.Documents.DateTools for date conversion.
The date resolution that shall be used for RangeQueries can be set using SetDateResolution(DateResolution) or SetDateResolution(string, DateResolution). 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 Lucene.Net.Documents.DateTools in your index, you can create your own query parser that inherits QueryParser and overwrites 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 Lucene.Net.Util.LuceneVersion compatibility when creating QueryParser:- As of 3.1, AutoGeneratePhraseQueries is false by default.
Declaration
public int Modifiers()
Returns
Type | Description |
---|---|
int |
Query(string)
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:- 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 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.
Query ::= ( Clause )*
Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
Examples of appropriately formatted queries can be found in the query syntax documentation.
In Lucene.Net.Search.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 CultureInfo. A Lucene.Net.Documents.DateResolution has to be set, if you want to use Lucene.Net.Documents.DateTools for date conversion.
The date resolution that shall be used for RangeQueries can be set using SetDateResolution(DateResolution) or SetDateResolution(string, DateResolution). 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 Lucene.Net.Documents.DateTools in your index, you can create your own query parser that inherits QueryParser and overwrites 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 Lucene.Net.Util.LuceneVersion compatibility when creating QueryParser:- As of 3.1, AutoGeneratePhraseQueries is false by default.
Declaration
public Query Query(string field)
Parameters
Type | Name | Description |
---|---|---|
string | field |
Returns
Type | Description |
---|---|
Query |
ReInit(ICharStream)
Reinitialize.
Declaration
public override void ReInit(ICharStream stream)
Parameters
Type | Name | Description |
---|---|---|
ICharStream | stream |
Overrides
ReInit(QueryParserTokenManager)
Reinitialize.
Declaration
public virtual void ReInit(QueryParserTokenManager tm)
Parameters
Type | Name | Description |
---|---|---|
QueryParserTokenManager | tm |
Term(string)
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:- 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 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.
Query ::= ( Clause )*
Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
Examples of appropriately formatted queries can be found in the query syntax documentation.
In Lucene.Net.Search.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 CultureInfo. A Lucene.Net.Documents.DateResolution has to be set, if you want to use Lucene.Net.Documents.DateTools for date conversion.
The date resolution that shall be used for RangeQueries can be set using SetDateResolution(DateResolution) or SetDateResolution(string, DateResolution). 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 Lucene.Net.Documents.DateTools in your index, you can create your own query parser that inherits QueryParser and overwrites 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 Lucene.Net.Util.LuceneVersion compatibility when creating QueryParser:- As of 3.1, AutoGeneratePhraseQueries is false by default.
Declaration
public Query Term(string field)
Parameters
Type | Name | Description |
---|---|---|
string | field |
Returns
Type | Description |
---|---|
Query |
TopLevelQuery(string)
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:- 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 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.
Query ::= ( Clause )*
Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )
Examples of appropriately formatted queries can be found in the query syntax documentation.
In Lucene.Net.Search.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 CultureInfo. A Lucene.Net.Documents.DateResolution has to be set, if you want to use Lucene.Net.Documents.DateTools for date conversion.
The date resolution that shall be used for RangeQueries can be set using SetDateResolution(DateResolution) or SetDateResolution(string, DateResolution). 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 Lucene.Net.Documents.DateTools in your index, you can create your own query parser that inherits QueryParser and overwrites 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 Lucene.Net.Util.LuceneVersion compatibility when creating QueryParser:- As of 3.1, AutoGeneratePhraseQueries is false by default.
Declaration
public override sealed Query TopLevelQuery(string field)
Parameters
Type | Name | Description |
---|---|---|
string | field |
Returns
Type | Description |
---|---|
Query |