org.apache.lucene.search
Class BooleanQuery
- Cloneable, Serializable
public class BooleanQuery
A Query that matches documents matching boolean combinations of other
queries, e.g.
TermQuery
s,
PhraseQuery
s or other
BooleanQuerys.
void | add(BooleanClause clause) - Adds a clause to a boolean query.
|
void | add(Query query, boolean required, boolean prohibited) - use
add(Query,BooleanClause.Occur) instead:
- For add(query, true, false) use add(query, BooleanClause.Occur.MUST)
- For add(query, false, false) use add(query, BooleanClause.Occur.SHOULD)
- For add(query, false, true) use add(query, BooleanClause.Occur.MUST_NOT)
|
void | add(Query query, BooleanClause.Occur occur) - Adds a clause to a boolean query.
|
Object | clone()
|
protected Weight | createWeight(Searcher searcher)
|
boolean | equals(Object o) - Returns true iff
o is equal to this.
|
void | extractTerms(Set terms)
|
BooleanClause[] | getClauses() - Returns the set of clauses in this query.
|
static int | getMaxClauseCount() - Return the maximum number of clauses permitted, 1024 by default.
|
int | getMinimumNumberShouldMatch() - Gets the minimum number of the optional BooleanClauses
which must be satisifed.
|
Similarity | getSimilarity(Searcher searcher)
|
static boolean | getUseScorer14()
|
int | hashCode() - Returns a hash code value for this object.
|
boolean | isCoordDisabled() - Returns true iff
Similarity.coord(int,int) is disabled in
scoring for this query instance.
|
Query | rewrite(IndexReader reader)
|
static void | setMaxClauseCount(int maxClauseCount) - Set the maximum number of clauses permitted per BooleanQuery.
|
void | setMinimumNumberShouldMatch(int min) - Specifies a minimum number of the optional BooleanClauses
which must be satisifed.
|
static void | setUseScorer14(boolean use14)
|
String | toString(String field) - Prints a user-readable version of this query.
|
clone , combine , createWeight , extractTerms , getBoost , getSimilarity , mergeBooleanQueries , rewrite , setBoost , toString , toString , weight |
minNrShouldMatch
protected int minNrShouldMatch
BooleanQuery
public BooleanQuery()
Constructs an empty boolean query.
BooleanQuery
public BooleanQuery(boolean disableCoord)
add
public void add(BooleanClause clause)
Adds a clause to a boolean query.
add
public void add(Query query,
boolean required,
boolean prohibited)
use add(Query,BooleanClause.Occur)
instead:
- For add(query, true, false) use add(query, BooleanClause.Occur.MUST)
- For add(query, false, false) use add(query, BooleanClause.Occur.SHOULD)
- For add(query, false, true) use add(query, BooleanClause.Occur.MUST_NOT)
Adds a clause to a boolean query. Clauses may be:
required
which means that documents which do not
match this sub-query will not match the boolean query;
prohibited
which means that documents which do
match this sub-query will not match the boolean query; or
- neither, in which case matched documents are neither prohibited from
nor required to match the sub-query. However, a document must match at
least 1 sub-query to match the boolean query.
It is an error to specify a clause as both
required
and
prohibited
.
clone
public Object clone()
- clone in interface Query
equals
public boolean equals(Object o)
Returns true iff o
is equal to this.
getClauses
public BooleanClause[] getClauses()
Returns the set of clauses in this query.
getMaxClauseCount
public static int getMaxClauseCount()
Return the maximum number of clauses permitted, 1024 by default.
Attempts to add more than the permitted number of clauses cause
BooleanQuery.TooManyClauses
to be thrown.
getMinimumNumberShouldMatch
public int getMinimumNumberShouldMatch()
Gets the minimum number of the optional BooleanClauses
which must be satisifed.
getUseScorer14
public static boolean getUseScorer14()
hashCode
public int hashCode()
Returns a hash code value for this object.
isCoordDisabled
public boolean isCoordDisabled()
setMaxClauseCount
public static void setMaxClauseCount(int maxClauseCount)
Set the maximum number of clauses permitted per BooleanQuery.
Default value is 1024.
TermQuery clauses are generated from for example prefix queries and
fuzzy queries. Each TermQuery needs some buffer space during search,
so this parameter indirectly controls the maximum buffer requirements for
query search.
When this parameter becomes a bottleneck for a Query one can use a
Filter. For example instead of a
RangeQuery
one can use a
RangeFilter
.
Normally the buffers are allocated by the JVM. When using for example
MMapDirectory
the buffering is left to
the operating system.
setMinimumNumberShouldMatch
public void setMinimumNumberShouldMatch(int min)
Specifies a minimum number of the optional BooleanClauses
which must be satisifed.
By default no optional clauses are neccessary for a match
(unless there are no required clauses). If this method is used,
then the specified numebr of clauses is required.
Use of this method is totally independant of specifying that
any specific clauses are required (or prohibited). This number will
only be compared against the number of matching optional clauses.
EXPERT NOTE: Using this method will force the use of BooleanWeight2,
regardless of wether setUseScorer14(true) has been called.
min
- the number of optional clauses that must match
setUseScorer14
public static void setUseScorer14(boolean use14)
toString
public String toString(String field)
Prints a user-readable version of this query.
- toString in interface Query
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.