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 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
The date resolution that shall be used for RangeQueries can be set
using
If you don't use
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
- 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
| Improve this Doc View SourceQueryParser(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. |
System.String | f | the default field for query terms. |
Analyzer | a | used to find terms in the query text. |
Properties
| Improve this Doc View SourceJj_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
| Improve this Doc View SourceClause(String)
Declaration
public Query Clause(string field)
Parameters
Type | Name | Description |
---|---|---|
System.String | field |
Returns
Type | Description |
---|---|
Query |
Conjunction()
Declaration
public int Conjunction()
Returns
Type | Description |
---|---|
System.Int32 |
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(Int32)
Get the specific Token.
Declaration
public Token GetToken(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Returns
Type | Description |
---|---|
Token |
Modifiers()
Declaration
public int Modifiers()
Returns
Type | Description |
---|---|
System.Int32 |
Query(String)
Declaration
public Query Query(string field)
Parameters
Type | Name | Description |
---|---|---|
System.String | field |
Returns
Type | Description |
---|---|
Query |
ReInit(ICharStream)
Reinitialize.
Declaration
public override void ReInit(ICharStream stream)
Parameters
Type | Name | Description |
---|---|---|
ICharStream | stream |
Overrides
| Improve this Doc View SourceReInit(QueryParserTokenManager)
Reinitialize.
Declaration
public virtual void ReInit(QueryParserTokenManager tm)
Parameters
Type | Name | Description |
---|---|---|
QueryParserTokenManager | tm |
Term(String)
Declaration
public Query Term(string field)
Parameters
Type | Name | Description |
---|---|---|
System.String | field |
Returns
Type | Description |
---|---|
Query |
TopLevelQuery(String)
Declaration
public override sealed Query TopLevelQuery(string field)
Parameters
Type | Name | Description |
---|---|---|
System.String | field |
Returns
Type | Description |
---|---|
Query |