org.apache.lucene.search
Class BooleanQuery
- Cloneable, java.io.Serializable
public class BooleanQuery
A Query that matches documents matching boolean combinations of other
queries, typically
TermQuery
s or
PhraseQuery
s.
void | add(BooleanClause clause) - Adds a clause to a boolean query.
|
void | add(Query query, boolean required, boolean prohibited) - Adds a clause to a boolean query.
|
Object | clone() - Returns a clone of this query.
|
protected Weight | createWeight(Searcher searcher) - Expert: Constructs an appropriate Weight implementation for this query.
|
boolean | equals(Object o) - Returns true iff
o is equal to this.
|
BooleanClause[] | getClauses() - Returns the set of clauses in this query.
|
static int | getMaxClauseCount() - Return the maximum number of clauses permitted, 1024 by default.
|
int | hashCode() - Returns a hash code value for this object.
|
Query | rewrite(IndexReader reader) - Expert: called to re-write queries into primitive queries.
|
static void | setMaxClauseCount(int maxClauseCount) - Set the maximum number of clauses permitted.
|
String | toString(String field) - Prints a user-readable version of this query.
|
clone , combine , createWeight , getBoost , getSimilarity , mergeBooleanQueries , rewrite , setBoost , toString , toString , weight |
maxClauseCount
public static int maxClauseCount
Default value is 1024. Use org.apache.lucene.maxClauseCount
system property to override.
BooleanQuery
public BooleanQuery()
Constructs an empty boolean query.
add
public void add(BooleanClause clause)
Adds a clause to a boolean query.
add
public void add(Query query,
boolean required,
boolean prohibited)
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()
Returns a clone of this query.
- clone in interface Query
createWeight
protected Weight createWeight(Searcher searcher)
Expert: Constructs an appropriate Weight implementation for this query.
Only implemented by primitive queries, which re-write to themselves.
- createWeight 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.
hashCode
public int hashCode()
Returns a hash code value for this object.
rewrite
public Query rewrite(IndexReader reader)
throws IOException
Expert: called to re-write queries into primitive queries.
- rewrite in interface Query
setMaxClauseCount
public static void setMaxClauseCount(int maxClauseCount)
Set the maximum number of clauses permitted.
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.