Show / Hide Table of Contents

    Class BooleanQuery

    A Query that matches documents matching boolean combinations of other queries, e.g. TermQuerys, PhraseQuerys or other BooleanQuerys.

    Collection initializer note: To create and populate a BooleanQuery in a single statement, you can use the following example as a guide:

    var booleanQuery = new BooleanQuery() {
        { new WildcardQuery(new Term("field2", "foobar")), Occur.SHOULD },
        { new MultiPhraseQuery() {
            new Term("field", "microsoft"), 
            new Term("field", "office")
        }, Occur.SHOULD }
    };
    
    // or
    
    var booleanQuery = new BooleanQuery() {
        new BooleanClause(new WildcardQuery(new Term("field2", "foobar")), Occur.SHOULD),
        new BooleanClause(new MultiPhraseQuery() {
            new Term("field", "microsoft"), 
            new Term("field", "office")
        }, Occur.SHOULD)
    };
    Inheritance
    System.Object
    Query
    BooleanQuery
    Implements
    IEnumerable<BooleanClause>
    Inherited Members
    Query.Boost
    Query.ToString()
    Namespace: Lucene.Net.Search
    Assembly: Lucene.Net.dll
    Syntax
    public class BooleanQuery : Query, IEnumerable<BooleanClause>

    Constructors

    | Improve this Doc View Source

    BooleanQuery()

    Constructs an empty boolean query.

    Declaration
    public BooleanQuery()
    | Improve this Doc View Source

    BooleanQuery(Boolean)

    Constructs an empty boolean query.

    Coord(Int32, Int32) may be disabled in scoring, as appropriate. For example, this score factor does not make sense for most automatically generated queries, like WildcardQuery and FuzzyQuery.

    Declaration
    public BooleanQuery(bool disableCoord)
    Parameters
    Type Name Description
    System.Boolean disableCoord

    Disables Coord(Int32, Int32) in scoring.

    Fields

    | Improve this Doc View Source

    m_minNrShouldMatch

    Declaration
    protected int m_minNrShouldMatch
    Field Value
    Type Description
    System.Int32

    Properties

    | Improve this Doc View Source

    Clauses

    Returns the list of clauses in this query.

    Declaration
    public virtual IList<BooleanClause> Clauses { get; }
    Property Value
    Type Description
    IList<BooleanClause>
    | Improve this Doc View Source

    CoordDisabled

    Returns true if Coord(Int32, Int32) is disabled in scoring for this query instance.

    Declaration
    public virtual bool CoordDisabled { get; }
    Property Value
    Type Description
    System.Boolean
    See Also
    BooleanQuery(Boolean)
    | Improve this Doc View Source

    MaxClauseCount

    Return the maximum number of clauses permitted, 1024 by default. Attempts to add more than the permitted number of clauses cause BooleanQuery.TooManyClausesException to be thrown.

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

    MinimumNumberShouldMatch

    Specifies a minimum number of the optional BooleanClauses which must be satisfied.

    By default no optional clauses are necessary for a match (unless there are no required clauses). If this method is used, then the specified number of clauses is required.

    Use of this method is totally independent of specifying that any specific clauses are required (or prohibited). This number will only be compared against the number of matching optional clauses.

    Declaration
    public virtual int MinimumNumberShouldMatch { get; set; }
    Property Value
    Type Description
    System.Int32

    Methods

    | Improve this Doc View Source

    Add(BooleanClause)

    Adds a clause to a boolean query.

    Declaration
    public virtual void Add(BooleanClause clause)
    Parameters
    Type Name Description
    BooleanClause clause
    Exceptions
    Type Condition
    BooleanQuery.TooManyClausesException

    If the new number of clauses exceeds the maximum clause number

    See Also
    MaxClauseCount
    | Improve this Doc View Source

    Add(Query, Occur)

    Adds a clause to a boolean query.

    Declaration
    public virtual void Add(Query query, Occur occur)
    Parameters
    Type Name Description
    Query query
    Occur occur
    Exceptions
    Type Condition
    BooleanQuery.TooManyClausesException

    If the new number of clauses exceeds the maximum clause number

    See Also
    MaxClauseCount
    | Improve this Doc View Source

    Clone()

    Declaration
    public override object Clone()
    Returns
    Type Description
    System.Object
    Overrides
    Query.Clone()
    | Improve this Doc View Source

    CreateWeight(IndexSearcher)

    Declaration
    public override Weight CreateWeight(IndexSearcher searcher)
    Parameters
    Type Name Description
    IndexSearcher searcher
    Returns
    Type Description
    Weight
    Overrides
    Query.CreateWeight(IndexSearcher)
    | Improve this Doc View Source

    Equals(Object)

    Returns true if o is equal to this.

    Declaration
    public override bool Equals(object o)
    Parameters
    Type Name Description
    System.Object o
    Returns
    Type Description
    System.Boolean
    Overrides
    Query.Equals(Object)
    | Improve this Doc View Source

    ExtractTerms(ISet<Term>)

    Declaration
    public override void ExtractTerms(ISet<Term> terms)
    Parameters
    Type Name Description
    ISet<Term> terms
    Overrides
    Query.ExtractTerms(ISet<Term>)
    | Improve this Doc View Source

    GetClauses()

    Returns the set of clauses in this query.

    Declaration
    public virtual BooleanClause[] GetClauses()
    Returns
    Type Description
    BooleanClause[]
    | Improve this Doc View Source

    GetEnumerator()

    Returns an iterator on the clauses in this query. It implements the IEnumerable{BooleanClause} interface to make it possible to do:

    foreach (BooleanClause clause in booleanQuery) {}
    Declaration
    public IEnumerator<BooleanClause> GetEnumerator()
    Returns
    Type Description
    IEnumerator<BooleanClause>
    | Improve this Doc View Source

    GetHashCode()

    Returns a hash code value for this object.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    Query.GetHashCode()
    | Improve this Doc View Source

    Rewrite(IndexReader)

    Declaration
    public override Query Rewrite(IndexReader reader)
    Parameters
    Type Name Description
    IndexReader reader
    Returns
    Type Description
    Query
    Overrides
    Query.Rewrite(IndexReader)
    | Improve this Doc View Source

    ToString(String)

    Prints a user-readable version of this query.

    Declaration
    public override string ToString(string field)
    Parameters
    Type Name Description
    System.String field
    Returns
    Type Description
    System.String
    Overrides
    Query.ToString(String)

    Implements

    IEnumerable<>
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)