Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class MultiFieldQueryParser

    A QueryParser which constructs queries to search multiple fields.

    Inheritance
    System.Object
    Lucene.Net.Util.QueryBuilder
    QueryParserBase
    QueryParser
    MultiFieldQueryParser
    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(Int32)
    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>, Int32, Int32, Query)
    QueryParserBase.NewFieldQuery(Analyzer, String, String, Boolean)
    QueryParserBase.NewBooleanClause(Query, Occur)
    QueryParserBase.NewPrefixQuery(Term)
    QueryParserBase.NewRegexpQuery(Term)
    QueryParserBase.NewFuzzyQuery(Term, Single, Int32)
    QueryParserBase.AnalyzeMultitermTerm(String, String, Analyzer)
    QueryParserBase.NewRangeQuery(String, String, String, Boolean, Boolean)
    QueryParserBase.NewMatchAllDocsQuery()
    QueryParserBase.NewWildcardQuery(Term)
    QueryParserBase.GetBooleanQuery(IList<BooleanClause>)
    QueryParserBase.GetBooleanQuery(IList<BooleanClause>, Boolean)
    QueryParserBase.Escape(String)
    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 class MultiFieldQueryParser : QueryParser, ICommonQueryParserConfiguration

    Constructors

    | Improve this Doc View Source

    MultiFieldQueryParser(LuceneVersion, String[], Analyzer)

    Creates a MultiFieldQueryParser.

    It will, when Parse(String) is called, construct a query like this (assuming the query consists of two terms and you specify the two fields title and body):

    (title:term1 body:term1) (title:term2 body:term2)

    When DefaultOperator is set to AND_OPERATOR, the result will be:

    +(title:term1 body:term1) +(title:term2 body:term2)

    In other words, all the query's terms must appear, but it doesn't matter in what fields they appear.

    Declaration
    public MultiFieldQueryParser(LuceneVersion matchVersion, string[] fields, Analyzer analyzer)
    Parameters
    Type Name Description
    Lucene.Net.Util.LuceneVersion matchVersion
    System.String[] fields
    Lucene.Net.Analysis.Analyzer analyzer
    | Improve this Doc View Source

    MultiFieldQueryParser(LuceneVersion, String[], Analyzer, IDictionary<String, Single>)

    Creates a MultiFieldQueryParser. Allows passing of a map with term to Boost, and the boost to apply to each term.

    It will, when Parse(String) is called, construct a query like this (assuming the query consists of two terms and you specify the two fields title and body):

    (title:term1 body:term1) (title:term2 body:term2)

    When DefaultOperator is set to AND_OPERATOR, the result will be:

    +(title:term1 body:term1) +(title:term2 body:term2)

    When you pass a boost (title=>5 body=>10) you can get

    +(title:term1^5.0 body:term1^10.0) +(title:term2^5.0 body:term2^10.0)

    In other words, all the query's terms must appear, but it doesn't matter in what fields they appear.

    Declaration
    public MultiFieldQueryParser(LuceneVersion matchVersion, string[] fields, Analyzer analyzer, IDictionary<string, float> boosts)
    Parameters
    Type Name Description
    Lucene.Net.Util.LuceneVersion matchVersion
    System.String[] fields
    Lucene.Net.Analysis.Analyzer analyzer
    System.Collections.Generic.IDictionary<System.String, System.Single> boosts

    Fields

    | Improve this Doc View Source

    m_boosts

    Declaration
    protected IDictionary<string, float> m_boosts
    Field Value
    Type Description
    System.Collections.Generic.IDictionary<System.String, System.Single>
    | Improve this Doc View Source

    m_fields

    Declaration
    protected string[] m_fields
    Field Value
    Type Description
    System.String[]

    Methods

    | Improve this Doc View Source

    GetFieldQuery(String, String, Boolean)

    Declaration
    protected override 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
    Overrides
    QueryParserBase.GetFieldQuery(String, String, Boolean)
    | Improve this Doc View Source

    GetFieldQuery(String, String, Int32)

    Declaration
    protected override 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
    Overrides
    QueryParserBase.GetFieldQuery(String, String, Int32)
    | Improve this Doc View Source

    GetFuzzyQuery(String, String, Single)

    Declaration
    protected override Query GetFuzzyQuery(string field, string termStr, float minSimilarity)
    Parameters
    Type Name Description
    System.String field
    System.String termStr
    System.Single minSimilarity
    Returns
    Type Description
    Lucene.Net.Search.Query
    Overrides
    QueryParserBase.GetFuzzyQuery(String, String, Single)
    | Improve this Doc View Source

    GetPrefixQuery(String, String)

    Declaration
    protected override Query GetPrefixQuery(string field, string termStr)
    Parameters
    Type Name Description
    System.String field
    System.String termStr
    Returns
    Type Description
    Lucene.Net.Search.Query
    Overrides
    QueryParserBase.GetPrefixQuery(String, String)
    | Improve this Doc View Source

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

    Declaration
    protected override 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
    Overrides
    QueryParserBase.GetRangeQuery(String, String, String, Boolean, Boolean)
    | Improve this Doc View Source

    GetRegexpQuery(String, String)

    Declaration
    protected override Query GetRegexpQuery(string field, string termStr)
    Parameters
    Type Name Description
    System.String field
    System.String termStr
    Returns
    Type Description
    Lucene.Net.Search.Query
    Overrides
    QueryParserBase.GetRegexpQuery(String, String)
    | Improve this Doc View Source

    GetWildcardQuery(String, String)

    Declaration
    protected override Query GetWildcardQuery(string field, string termStr)
    Parameters
    Type Name Description
    System.String field
    System.String termStr
    Returns
    Type Description
    Lucene.Net.Search.Query
    Overrides
    QueryParserBase.GetWildcardQuery(String, String)
    | Improve this Doc View Source

    Parse(LuceneVersion, String, String[], Occur[], Analyzer)

    Parses a query, searching on the fields specified. Use this if you need to specify certain fields as required, and others as prohibited.

    Usage:

        string[] fields = {"filename", "contents", "description"};
        Occur[] flags = {Occur.SHOULD,
            Occur.MUST,
            Occur.MUST_NOT};
        MultiFieldQueryParser.Parse("query", fields, flags, analyzer);

    The code above would construct a query:

    (filename:query) +(contents:query) -(description:query)
    Declaration
    public static Query Parse(LuceneVersion matchVersion, string query, string[] fields, Occur[] flags, Analyzer analyzer)
    Parameters
    Type Name Description
    Lucene.Net.Util.LuceneVersion matchVersion

    Lucene version to match; this is passed through to QueryParser.

    System.String query

    Query string to parse

    System.String[] fields

    Fields to search on

    Lucene.Net.Search.Occur[] flags

    Flags describing the fields

    Lucene.Net.Analysis.Analyzer analyzer

    Analyzer to use

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

    if query parsing fails

    System.ArgumentException

    if the length of the fields array differs from the length of the flags array

    | Improve this Doc View Source

    Parse(LuceneVersion, String[], String[], Analyzer)

    Parses a query which searches on the fields specified.

    If x fields are specified, this effectively constructs:

    (field1:query1) (field2:query2) (field3:query3)...(fieldx:queryx)
    Declaration
    public static Query Parse(LuceneVersion matchVersion, string[] queries, string[] fields, Analyzer analyzer)
    Parameters
    Type Name Description
    Lucene.Net.Util.LuceneVersion matchVersion

    Lucene version to match; this is passed through to QueryParser.

    System.String[] queries

    Queries strings to parse

    System.String[] fields

    Fields to search on

    Lucene.Net.Analysis.Analyzer analyzer

    Analyzer to use

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

    if query parsing fails

    System.ArgumentException

    if the length of the queries array differs from the length of the fields array

    | Improve this Doc View Source

    Parse(LuceneVersion, String[], String[], Occur[], Analyzer)

    Parses a query, searching on the fields specified. Use this if you need to specify certain fields as required, and others as prohibited.

    Usage:

        string[] query = {"query1", "query2", "query3"};
        string[] fields = {"filename", "contents", "description"};
        Occur[] flags = {Occur.SHOULD,
            Occur.MUST,
            Occur.MUST_NOT};
        MultiFieldQueryParser.Parse(query, fields, flags, analyzer);

    The code above would construct a query:

    (filename:query1) +(contents:query2) -(description:query3)
    Declaration
    public static Query Parse(LuceneVersion matchVersion, string[] queries, string[] fields, Occur[] flags, Analyzer analyzer)
    Parameters
    Type Name Description
    Lucene.Net.Util.LuceneVersion matchVersion

    Lucene version to match; this is passed through to QueryParser.

    System.String[] queries

    Queries string to parse

    System.String[] fields

    Fields to search on

    Lucene.Net.Search.Occur[] flags

    Flags describing the fields

    Lucene.Net.Analysis.Analyzer analyzer

    Analyzer to use

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

    if query parsing fails

    System.ArgumentException

    if the length of the queries, fields, and flags array differ

    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.