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)
};
Assembly: DistributedLucene.Net.dll
Syntax
public class BooleanQuery : Query, IEnumerable<BooleanClause>
Constructors
Name | Description |
---|---|
BooleanQuery() | Constructs an empty boolean query. |
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. |
Fields
Name | Description |
---|---|
m_minNrShouldMatch |
Properties
Name | Description |
---|---|
Clauses | Returns the list of clauses in this query. |
CoordDisabled | Returns true if Coord(Int32, Int32) is disabled in scoring for this query instance. |
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. |
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. |
Methods
Name | Description |
---|---|
Add(BooleanClause) | Adds a clause to a boolean query. |
Add(Query, Occur) | Adds a clause to a boolean query. |
Clone() | |
CreateWeight(IndexSearcher) | |
Equals(Object) | Returns |
ExtractTerms(ISet<Term>) | |
GetClauses() | Returns the set of clauses in this query. |
GetEnumerator() | Returns an iterator on the clauses in this query. It implements the IEnumerable{BooleanClause} interface to make it possible to do:
|
GetHashCode() | Returns a hash code value for this object. |
Rewrite(IndexReader) | |
ToString(String) | Prints a user-readable version of this query. |