Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class AnalyzingQueryParser

    Overrides Lucene's default QueryParser so that Fuzzy-, Prefix-, Range-, and WildcardQuerys are also passed through the given analyzer, but wildcard characters * and ? don't get removed from the search terms.

    Warning: This class should only be used with analyzers that do not use stopwords or that add tokens. Also, several stemming analyzers are inappropriate: for example, Lucene.Net.Analysis.De.GermanAnalyzer will turn Häuser into hau, but H?user will become h?user when using this parser and thus no match would be found (i.e. using this parser will be no improvement over QueryParser in such cases).
    Inheritance
    object
    QueryBuilder
    QueryParserBase
    QueryParser
    AnalyzingQueryParser
    Implements
    ICommonQueryParserConfiguration
    Inherited Members
    QueryParser.Conjunction()
    QueryParser.Modifiers()
    QueryParser.TopLevelQuery(string)
    QueryParser.Query(string)
    QueryParser.Clause(string)
    QueryParser.Term(string)
    QueryParser.TokenSource
    QueryParser.Token
    QueryParser.Jj_nt
    QueryParser.ReInit(ICharStream)
    QueryParser.ReInit(QueryParserTokenManager)
    QueryParser.GetNextToken()
    QueryParser.GetToken(int)
    QueryParser.GenerateParseException()
    QueryParser.Enable_tracing()
    QueryParser.Disable_tracing()
    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.GetRegexpQuery(string, string)
    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.Analyzing
    Assembly: Lucene.Net.QueryParser.dll
    Syntax
    public class AnalyzingQueryParser : QueryParser, ICommonQueryParserConfiguration

    Constructors

    AnalyzingQueryParser(LuceneVersion, string, Analyzer)

    Overrides Lucene's default QueryParser so that Fuzzy-, Prefix-, Range-, and WildcardQuerys are also passed through the given analyzer, but wildcard characters * and ? don't get removed from the search terms.

    Warning: This class should only be used with analyzers that do not use stopwords or that add tokens. Also, several stemming analyzers are inappropriate: for example, Lucene.Net.Analysis.De.GermanAnalyzer will turn Häuser into hau, but H?user will become h?user when using this parser and thus no match would be found (i.e. using this parser will be no improvement over QueryParser in such cases).
    Declaration
    public AnalyzingQueryParser(LuceneVersion matchVersion, string field, Analyzer analyzer)
    Parameters
    Type Name Description
    LuceneVersion matchVersion
    string field
    Analyzer analyzer

    Methods

    AnalyzeSingleChunk(string, string, string)

    Returns the analyzed form for the given chunk.

    If the analyzer produces more than one output token from the given chunk, a ParseException is thrown.

    Declaration
    protected virtual string AnalyzeSingleChunk(string field, string termStr, string chunk)
    Parameters
    Type Name Description
    string field

    The target field

    string termStr

    The full term from which the given chunk is excerpted

    string chunk

    The portion of the given termStr to be analyzed

    Returns
    Type Description
    string

    The result of analyzing the given chunk

    Exceptions
    Type Condition
    ParseException

    ParseException when analysis returns other than one output token

    GetFuzzyQuery(string, string, float)

    Called when parser parses an input term that has the fuzzy suffix (~) appended.

    Depending on analyzer and settings, a fuzzy term may (most probably will) be lower-cased automatically. It will go through the default Analyzer.

    Overrides super class, by passing terms through analyzer.
    Declaration
    protected override Query GetFuzzyQuery(string field, string termStr, float minSimilarity)
    Parameters
    Type Name Description
    string field

    Name of the field query will use.

    string termStr

    Term to use for building term for the query

    float minSimilarity
    Returns
    Type Description
    Query

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

    Overrides
    QueryParserBase.GetFuzzyQuery(string, string, float)

    GetPrefixQuery(string, string)

    Called when parser parses an input term 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 analyzer and settings, a prefix term may (most probably will) be lower-cased automatically. It will go through the default Analyzer.

    Overrides super class, by passing terms through analyzer.
    Declaration
    protected override Query GetPrefixQuery(string field, string termStr)
    Parameters
    Type Name Description
    string field

    Name of the field query will use.

    string termStr

    Term to use for building term for the query (without trailing '*' character!)

    Returns
    Type Description
    Query

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

    Overrides
    QueryParserBase.GetPrefixQuery(string, string)

    GetWildcardQuery(string, string)

    Called when parser parses an input term 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 analyzer and settings, a prefix term may (most probably will) be lower-cased automatically. It will go through the default Analyzer.

    Overrides super class, by passing terms through analyzer.
    Declaration
    protected override Query GetWildcardQuery(string field, string termStr)
    Parameters
    Type Name Description
    string field

    Name of the field query will use.

    string termStr

    Term to use for building term for the query (without trailing '*' character!)

    Returns
    Type Description
    Query

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

    Overrides
    QueryParserBase.GetWildcardQuery(string, 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.