Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class QueryParserBase

    This class is overridden by QueryParser.

    Inheritance
    System.Object
    Lucene.Net.Util.QueryBuilder
    QueryParserBase
    QueryParser
    Implements
    ICommonQueryParserConfiguration
    Inherited Members
    QueryBuilder.CreateBooleanQuery(String, String)
    QueryBuilder.CreateBooleanQuery(String, String, Occur)
    QueryBuilder.CreatePhraseQuery(String, String)
    QueryBuilder.CreatePhraseQuery(String, String, Int32)
    QueryBuilder.CreateMinShouldMatchQuery(String, String, Single)
    Lucene.Net.Util.QueryBuilder.Analyzer
    Lucene.Net.Util.QueryBuilder.EnablePositionIncrements
    QueryBuilder.CreateFieldQuery(Analyzer, Occur, String, String, Boolean, Int32)
    QueryBuilder.NewBooleanQuery(Boolean)
    Lucene.Net.Util.QueryBuilder.NewTermQuery(Lucene.Net.Index.Term)
    Lucene.Net.Util.QueryBuilder.NewPhraseQuery()
    Lucene.Net.Util.QueryBuilder.NewMultiPhraseQuery()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Lucene.Net.QueryParsers.Classic
    Assembly: Lucene.Net.QueryParser.dll
    Syntax
    public abstract class QueryParserBase : QueryBuilder, ICommonQueryParserConfiguration

    Constructors

    | Improve this Doc View Source

    QueryParserBase()

    So the generated QueryParser(CharStream) won't error out

    Declaration
    protected QueryParserBase()

    Fields

    | Improve this Doc View Source

    AND_OPERATOR

    Alternative form of AND

    Declaration
    public const Operator AND_OPERATOR = Operator.AND
    Field Value
    Type Description
    Operator
    | Improve this Doc View Source

    CONJ_AND

    Declaration
    protected const int CONJ_AND = 1
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    CONJ_NONE

    Declaration
    protected const int CONJ_NONE = 0
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    CONJ_OR

    Declaration
    protected const int CONJ_OR = 2
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    m_field

    Declaration
    protected string m_field
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    MOD_NONE

    Declaration
    protected const int MOD_NONE = 0
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    MOD_NOT

    Declaration
    protected const int MOD_NOT = 10
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    MOD_REQ

    Declaration
    protected const int MOD_REQ = 11
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    OR_OPERATOR

    Alternative form of OR

    Declaration
    public const Operator OR_OPERATOR = Operator.OR
    Field Value
    Type Description
    Operator

    Properties

    | Improve this Doc View Source

    AllowLeadingWildcard

    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.

    Declaration
    public virtual bool AllowLeadingWildcard { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    AnalyzeRangeTerms

    Get or Set whether or not to analyze range terms when constructing Lucene.Net.Search.TermRangeQuerys. For example, setting this to true can enable analyzing terms into collation keys for locale-sensitive Lucene.Net.Search.TermRangeQuery.

    Declaration
    public virtual bool AnalyzeRangeTerms { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    AutoGeneratePhraseQueries

    Set to true if phrase queries will be automatically generated when the analyzer returns more than one term from whitespace delimited text. NOTE: this behavior may not be suitable for all languages.

    Set to false if phrase queries should only be generated when surrounded by double quotes.

    Declaration
    public bool AutoGeneratePhraseQueries { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    DefaultOperator

    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

    Declaration
    public virtual Operator DefaultOperator { get; set; }
    Property Value
    Type Description
    Operator
    | Improve this Doc View Source

    Field

    Returns the default field.

    Declaration
    public virtual string Field { get; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    FuzzyMinSim

    Get or Set the minimum similarity for fuzzy queries. Default is 2f.

    Declaration
    public virtual float FuzzyMinSim { get; set; }
    Property Value
    Type Description
    System.Single
    | Improve this Doc View Source

    FuzzyPrefixLength

    Get or Set the prefix length for fuzzy queries. Default is 0.

    Declaration
    public virtual int FuzzyPrefixLength { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Locale

    Get or Set locale used by date range parsing, lowercasing, and other locale-sensitive operations.

    By default, the culture is null, which indicates to read the culture on the fly from System.Globalization.CultureInfo.CurrentCulture. This ensures if you change the culture on the current thread, QueryParser will utilize it. You can also explicitly set a culture. Setting the culture to null will restore the default behavior if you have explicitly set a culture.

    Declaration
    public virtual CultureInfo Locale { get; set; }
    Property Value
    Type Description
    System.Globalization.CultureInfo
    | Improve this Doc View Source

    LowercaseExpandedTerms

    Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. Default is true.

    Declaration
    public virtual bool LowercaseExpandedTerms { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    MultiTermRewriteMethod

    By default QueryParser uses Lucene.Net.Search.MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT when creating a Lucene.Net.Search.PrefixQuery, Lucene.Net.Search.WildcardQuery or Lucene.Net.Search.TermRangeQuery. This implementation is generally preferable because it a) Runs faster b) Does not have the scarcity of terms unduly influence score c) avoids any Lucene.Net.Search.BooleanQuery.TooManyClausesException exception. However, if your application really needs to use the old-fashioned Lucene.Net.Search.BooleanQuery expansion rewriting and the above points are not relevant then use this to change the rewrite method.

    Declaration
    public virtual MultiTermQuery.RewriteMethod MultiTermRewriteMethod { get; set; }
    Property Value
    Type Description
    Lucene.Net.Search.MultiTermQuery.RewriteMethod
    | Improve this Doc View Source

    PhraseSlop

    Gets or Sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero.

    Declaration
    public virtual int PhraseSlop { get; set; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    TimeZone

    Get or Set the current time zone for date and time parsing operations.

    By default, the time zone is null, which indicates to read the time zone on the fly from System.TimeZoneInfo.Local. This ensures if you change the time zone on the current system, QueryParser will utilize it. You can also explicitly set a time zone. Setting the time zone to null will restore the default behavior if you have explicitly set a time zone.

    Declaration
    public virtual TimeZoneInfo TimeZone { get; set; }
    Property Value
    Type Description
    System.TimeZoneInfo

    Methods

    | Improve this Doc View Source

    AddClause(IList<BooleanClause>, Int32, Int32, Query)

    Declaration
    protected virtual void AddClause(IList<BooleanClause> clauses, int conj, int mods, Query q)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Lucene.Net.Search.BooleanClause> clauses
    System.Int32 conj
    System.Int32 mods
    Lucene.Net.Search.Query q
    | Improve this Doc View Source

    AnalyzeMultitermTerm(String, String, Analyzer)

    Declaration
    protected virtual BytesRef AnalyzeMultitermTerm(string field, string part, Analyzer analyzerIn)
    Parameters
    Type Name Description
    System.String field
    System.String part
    Lucene.Net.Analysis.Analyzer analyzerIn
    Returns
    Type Description
    Lucene.Net.Util.BytesRef
    | Improve this Doc View Source

    Escape(String)

    Returns a string where those characters that QueryParser expects to be escaped are escaped by a preceding

    \
    .

    Declaration
    public static string Escape(string s)
    Parameters
    Type Name Description
    System.String s
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    GetBooleanQuery(IList<BooleanClause>)

    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.

    Declaration
    protected virtual Query GetBooleanQuery(IList<BooleanClause> clauses)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Lucene.Net.Search.BooleanClause> clauses

    List that contains Lucene.Net.Search.BooleanClause instances to join.

    Returns
    Type Description
    Lucene.Net.Search.Query

    Resulting Lucene.Net.Search.Query object.

    Exceptions
    Type Condition
    ParseException

    throw in overridden method to disallow

    | Improve this Doc View Source

    GetBooleanQuery(IList<BooleanClause>, Boolean)

    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.

    Declaration
    protected virtual Query GetBooleanQuery(IList<BooleanClause> clauses, bool disableCoord)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Lucene.Net.Search.BooleanClause> clauses

    List that contains Lucene.Net.Search.BooleanClause instances to join.

    System.Boolean disableCoord

    true if coord scoring should be disabled.

    Returns
    Type Description
    Lucene.Net.Search.Query

    Resulting Lucene.Net.Search.Query object.

    Exceptions
    Type Condition
    ParseException

    throw in overridden method to disallow

    | Improve this Doc View Source

    GetDateResolution(String)

    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.

    Declaration
    public virtual DateResolution GetDateResolution(string fieldName)
    Parameters
    Type Name Description
    System.String fieldName
    Returns
    Type Description
    Lucene.Net.Documents.DateResolution
    | Improve this Doc View Source

    GetFieldQuery(String, String, Boolean)

    Declaration
    protected virtual Query GetFieldQuery(string field, string queryText, bool quoted)
    Parameters
    Type Name Description
    System.String field
    System.String queryText
    System.Boolean quoted
    Returns
    Type Description
    Lucene.Net.Search.Query
    Exceptions
    Type Condition
    ParseException

    throw in overridden method to disallow

    | Improve this Doc View Source

    GetFieldQuery(String, String, Int32)

    Base implementation delegates to GetFieldQuery(String, String, Boolean). This method may be overridden, for example, to return a Lucene.Net.Search.Spans.SpanNearQuery instead of a Lucene.Net.Search.PhraseQuery.

    Declaration
    protected virtual Query GetFieldQuery(string field, string queryText, int slop)
    Parameters
    Type Name Description
    System.String field
    System.String queryText
    System.Int32 slop
    Returns
    Type Description
    Lucene.Net.Search.Query
    Exceptions
    Type Condition
    ParseException

    throw in overridden method to disallow

    | Improve this Doc View Source

    GetFuzzyQuery(String, String, Single)

    Factory method for generating a query (similar to GetWildcardQuery(String, String)). Called when parser parses an input term token that has the fuzzy suffix (~) appended.

    Declaration
    protected virtual Query GetFuzzyQuery(string field, string termStr, float minSimilarity)
    Parameters
    Type Name Description
    System.String field

    Name of the field query will use.

    System.String termStr

    Term token to use for building term for the query

    System.Single minSimilarity

    minimum similarity

    Returns
    Type Description
    Lucene.Net.Search.Query

    Resulting Lucene.Net.Search.Query built for the term

    Exceptions
    Type Condition
    ParseException

    throw in overridden method to disallow

    | Improve this Doc View Source

    GetPrefixQuery(String, String)

    Factory method for generating a query (similar to GetWildcardQuery(String, String)). 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.

    Declaration
    protected virtual Query GetPrefixQuery(string field, string termStr)
    Parameters
    Type Name Description
    System.String field

    Name of the field query will use.

    System.String termStr

    Term token to use for building term for the query

    Returns
    Type Description
    Lucene.Net.Search.Query

    Resulting Lucene.Net.Search.Query built for the term

    Exceptions
    Type Condition
    ParseException

    throw in overridden method to disallow

    | Improve this Doc View Source

    GetRangeQuery(String, String, String, Boolean, Boolean)

    Declaration
    protected virtual Query GetRangeQuery(string field, string part1, string part2, bool startInclusive, bool endInclusive)
    Parameters
    Type Name Description
    System.String field
    System.String part1
    System.String part2
    System.Boolean startInclusive
    System.Boolean endInclusive
    Returns
    Type Description
    Lucene.Net.Search.Query
    | Improve this Doc View Source

    GetRegexpQuery(String, String)

    Factory method for generating a query. Called when parser parses an input term token that contains a regular expression query.

    Depending on settings, pattern term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with regular expression templates.

    Can be overridden by extending classes, to provide custom handling for regular expression queries, which may be necessary due to missing analyzer calls.

    Declaration
    protected virtual Query GetRegexpQuery(string field, string termStr)
    Parameters
    Type Name Description
    System.String field

    Name of the field query will use.

    System.String termStr

    Term token that contains a regular expression

    Returns
    Type Description
    Lucene.Net.Search.Query

    Resulting Lucene.Net.Search.Query built for the term

    Exceptions
    Type Condition
    ParseException

    throw in overridden method to disallow

    | Improve this Doc View Source

    GetWildcardQuery(String, String)

    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.

    Declaration
    protected virtual Query GetWildcardQuery(string field, string termStr)
    Parameters
    Type Name Description
    System.String field

    Name of the field query will use.

    System.String termStr

    Term token that contains one or more wild card characters (? or *), but is not simple prefix term

    Returns
    Type Description
    Lucene.Net.Search.Query

    Resulting Lucene.Net.Search.Query built for the term

    Exceptions
    Type Condition
    ParseException

    throw in overridden method to disallow

    | Improve this Doc View Source

    Init(LuceneVersion, String, Analyzer)

    Initializes a query parser. Called by the QueryParser constructor

    Declaration
    public virtual void Init(LuceneVersion matchVersion, string f, Analyzer a)
    Parameters
    Type Name Description
    Lucene.Net.Util.LuceneVersion matchVersion

    Lucene version to match.

    System.String f

    the default field for query terms.

    Lucene.Net.Analysis.Analyzer a

    used to find terms in the query text.

    | Improve this Doc View Source

    NewBooleanClause(Query, Occur)

    Builds a new Lucene.Net.Search.BooleanClause instance

    Declaration
    protected virtual BooleanClause NewBooleanClause(Query q, Occur occur)
    Parameters
    Type Name Description
    Lucene.Net.Search.Query q

    sub query

    Lucene.Net.Search.Occur occur

    how this clause should occur when matching documents

    Returns
    Type Description
    Lucene.Net.Search.BooleanClause

    new Lucene.Net.Search.BooleanClause instance

    | Improve this Doc View Source

    NewFieldQuery(Analyzer, String, String, Boolean)

    Declaration
    protected virtual Query NewFieldQuery(Analyzer analyzer, string field, string queryText, bool quoted)
    Parameters
    Type Name Description
    Lucene.Net.Analysis.Analyzer analyzer
    System.String field
    System.String queryText
    System.Boolean quoted
    Returns
    Type Description
    Lucene.Net.Search.Query
    Exceptions
    Type Condition
    ParseException

    throw in overridden method to disallow

    | Improve this Doc View Source

    NewFuzzyQuery(Term, Single, Int32)

    Builds a new Lucene.Net.Search.FuzzyQuery instance

    Declaration
    protected virtual Query NewFuzzyQuery(Term term, float minimumSimilarity, int prefixLength)
    Parameters
    Type Name Description
    Lucene.Net.Index.Term term

    Term

    System.Single minimumSimilarity

    minimum similarity

    System.Int32 prefixLength

    prefix length

    Returns
    Type Description
    Lucene.Net.Search.Query

    new Lucene.Net.Search.FuzzyQuery Instance

    | Improve this Doc View Source

    NewMatchAllDocsQuery()

    Builds a new Lucene.Net.Search.MatchAllDocsQuery instance

    Declaration
    protected virtual Query NewMatchAllDocsQuery()
    Returns
    Type Description
    Lucene.Net.Search.Query

    new Lucene.Net.Search.MatchAllDocsQuery instance

    | Improve this Doc View Source

    NewPrefixQuery(Term)

    Builds a new Lucene.Net.Search.PrefixQuery instance

    Declaration
    protected virtual Query NewPrefixQuery(Term prefix)
    Parameters
    Type Name Description
    Lucene.Net.Index.Term prefix

    Prefix term

    Returns
    Type Description
    Lucene.Net.Search.Query

    new Lucene.Net.Search.PrefixQuery instance

    | Improve this Doc View Source

    NewRangeQuery(String, String, String, Boolean, Boolean)

    Builds a new Lucene.Net.Search.TermRangeQuery instance

    Declaration
    protected virtual Query NewRangeQuery(string field, string part1, string part2, bool startInclusive, bool endInclusive)
    Parameters
    Type Name Description
    System.String field

    Field

    System.String part1

    min

    System.String part2

    max

    System.Boolean startInclusive

    true if the start of the range is inclusive

    System.Boolean endInclusive

    true if the end of the range is inclusive

    Returns
    Type Description
    Lucene.Net.Search.Query

    new Lucene.Net.Search.TermRangeQuery instance

    | Improve this Doc View Source

    NewRegexpQuery(Term)

    Builds a new Lucene.Net.Search.RegexpQuery instance

    Declaration
    protected virtual Query NewRegexpQuery(Term regexp)
    Parameters
    Type Name Description
    Lucene.Net.Index.Term regexp

    Regexp term

    Returns
    Type Description
    Lucene.Net.Search.Query

    new Lucene.Net.Search.RegexpQuery instance

    | Improve this Doc View Source

    NewWildcardQuery(Term)

    Builds a new Lucene.Net.Search.WildcardQuery instance

    Declaration
    protected virtual Query NewWildcardQuery(Term t)
    Parameters
    Type Name Description
    Lucene.Net.Index.Term t

    wildcard term

    Returns
    Type Description
    Lucene.Net.Search.Query

    new Lucene.Net.Search.WildcardQuery instance

    | Improve this Doc View Source

    Parse(String)

    Parses a query string, returning a Lucene.Net.Search.Query.

    Declaration
    public virtual Query Parse(string query)
    Parameters
    Type Name Description
    System.String query

    the query string to be parsed.

    Returns
    Type Description
    Lucene.Net.Search.Query
    Exceptions
    Type Condition
    ParseException

    if the parsing fails

    | Improve this Doc View Source

    ReInit(ICharStream)

    Declaration
    public abstract void ReInit(ICharStream stream)
    Parameters
    Type Name Description
    ICharStream stream
    | Improve this Doc View Source

    SetDateResolution(DateResolution)

    Gets or 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, DateResolution).

    Declaration
    public virtual void SetDateResolution(DateResolution dateResolution)
    Parameters
    Type Name Description
    Lucene.Net.Documents.DateResolution dateResolution
    | Improve this Doc View Source

    SetDateResolution(String, DateResolution)

    Sets the date resolution used by RangeQueries for a specific field.

    Declaration
    public virtual void SetDateResolution(string fieldName, DateResolution dateResolution)
    Parameters
    Type Name Description
    System.String fieldName

    field for which the date resolution is to be set

    Lucene.Net.Documents.DateResolution dateResolution

    date resolution to set

    | Improve this Doc View Source

    TopLevelQuery(String)

    Declaration
    public abstract Query TopLevelQuery(string field)
    Parameters
    Type Name Description
    System.String field
    Returns
    Type Description
    Lucene.Net.Search.Query

    Implements

    ICommonQueryParserConfiguration
    • Improve this Doc
    • View Source
    Back to top Copyright © 2022 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.