Fork me on GitHub
  • API

    Show / Hide Table of Contents

    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 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
    object
    QueryBuilder
    QueryParserBase
    QueryParser
    AnalyzingQueryParser
    MultiFieldQueryParser
    ComplexPhraseQueryParser
    ExtendableQueryParser
    Implements
    ICommonQueryParserConfiguration
    Inherited Members
    QueryParserBase.CONJ_NONE
    QueryParserBase.CONJ_AND
    QueryParserBase.CONJ_OR
    QueryParserBase.MOD_NONE
    QueryParserBase.MOD_NOT
    QueryParserBase.MOD_REQ
    QueryParserBase.AND_OPERATOR
    QueryParserBase.OR_OPERATOR
    QueryParserBase.m_field
    QueryParserBase.Init(LuceneVersion, string, Analyzer)
    QueryParserBase.Parse(string)
    QueryParserBase.Field
    QueryParserBase.AutoGeneratePhraseQueries
    QueryParserBase.FuzzyMinSim
    QueryParserBase.FuzzyPrefixLength
    QueryParserBase.PhraseSlop
    QueryParserBase.AllowLeadingWildcard
    QueryParserBase.DefaultOperator
    QueryParserBase.LowercaseExpandedTerms
    QueryParserBase.MultiTermRewriteMethod
    QueryParserBase.Locale
    QueryParserBase.TimeZone
    QueryParserBase.SetDateResolution(DateResolution)
    QueryParserBase.SetDateResolution(string, DateResolution)
    QueryParserBase.GetDateResolution(string)
    QueryParserBase.AnalyzeRangeTerms
    QueryParserBase.AddClause(IList<BooleanClause>, int, int, Query)
    QueryParserBase.GetFieldQuery(string, string, bool)
    QueryParserBase.NewFieldQuery(Analyzer, string, string, bool)
    QueryParserBase.GetFieldQuery(string, string, int)
    QueryParserBase.GetRangeQuery(string, string, string, bool, bool)
    QueryParserBase.NewBooleanClause(Query, Occur)
    QueryParserBase.NewPrefixQuery(Term)
    QueryParserBase.NewRegexpQuery(Term)
    QueryParserBase.NewFuzzyQuery(Term, float, int)
    QueryParserBase.AnalyzeMultitermTerm(string, string, Analyzer)
    QueryParserBase.NewRangeQuery(string, string, string, bool, bool)
    QueryParserBase.NewMatchAllDocsQuery()
    QueryParserBase.NewWildcardQuery(Term)
    QueryParserBase.GetBooleanQuery(IList<BooleanClause>)
    QueryParserBase.GetBooleanQuery(IList<BooleanClause>, bool)
    QueryParserBase.GetWildcardQuery(string, string)
    QueryParserBase.GetRegexpQuery(string, string)
    QueryParserBase.GetPrefixQuery(string, string)
    QueryParserBase.GetFuzzyQuery(string, string, float)
    QueryParserBase.Escape(string)
    QueryBuilder.CreateBooleanQuery(string, string)
    QueryBuilder.CreateBooleanQuery(string, string, Occur)
    QueryBuilder.CreatePhraseQuery(string, string)
    QueryBuilder.CreatePhraseQuery(string, string, int)
    QueryBuilder.CreateMinShouldMatchQuery(string, string, float)
    QueryBuilder.Analyzer
    QueryBuilder.EnablePositionIncrements
    QueryBuilder.CreateFieldQuery(Analyzer, Occur, string, string, bool, int)
    QueryBuilder.NewBooleanQuery(bool)
    QueryBuilder.NewTermQuery(Term)
    QueryBuilder.NewPhraseQuery()
    QueryBuilder.NewMultiPhraseQuery()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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 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 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 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 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 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 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 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 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
    QueryParserBase.ReInit(ICharStream)

    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 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 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 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 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
    Overrides
    QueryParserBase.TopLevelQuery(string)

    Implements

    ICommonQueryParserConfiguration
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.