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
BooleanQuery
Implements
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Lucene.Net.dll
Syntax
public class BooleanQuery : Query, IEnumerable<BooleanClause>, IEnumerable
Constructors
|
Improve this Doc
View Source
BooleanQuery()
Constructs an empty boolean query.
Declaration
|
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
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
|
Improve this Doc
View Source
CoordDisabled
Declaration
public virtual bool CoordDisabled { get; }
Property Value
Type |
Description |
System.Boolean |
|
See Also
|
Improve this Doc
View Source
MaxClauseCount
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
Exceptions
See Also
|
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
Exceptions
See Also
|
Improve this Doc
View Source
Clone()
Declaration
public override object Clone()
Returns
Type |
Description |
System.Object |
|
Overrides
|
Improve this Doc
View Source
CreateWeight(IndexSearcher)
Declaration
public override Weight CreateWeight(IndexSearcher searcher)
Parameters
Returns
Overrides
|
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
|
Improve this Doc
View Source
Declaration
public override void ExtractTerms(ISet<Term> terms)
Parameters
Type |
Name |
Description |
System.Collections.Generic.ISet<Term> |
terms |
|
Overrides
|
Improve this Doc
View Source
GetClauses()
Returns the set of clauses in this query.
Declaration
public virtual BooleanClause[] GetClauses()
Returns
|
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 |
System.Collections.Generic.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
|
Improve this Doc
View Source
Rewrite(IndexReader)
Declaration
public override Query Rewrite(IndexReader reader)
Parameters
Returns
Overrides
|
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
Explicit Interface Implementations
|
Improve this Doc
View Source
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type |
Description |
System.Collections.IEnumerator |
|
Implements
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable