|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.search.Query org.apache.lucene.search.BooleanQuery
public class BooleanQuery
A Query that matches documents matching boolean combinations of other
queries, e.g. TermQuery
s, PhraseQuery
s or other
BooleanQuerys.
Nested Class Summary | |
---|---|
protected class |
BooleanQuery.BooleanWeight
Expert: the Weight for BooleanQuery, used to normalize, score and explain these queries. |
static class |
BooleanQuery.TooManyClauses
Thrown when an attempt is made to add more than getMaxClauseCount() clauses. |
Field Summary | |
---|---|
protected int |
minNrShouldMatch
|
Constructor Summary | |
---|---|
BooleanQuery()
Constructs an empty boolean query. |
|
BooleanQuery(boolean disableCoord)
Constructs an empty boolean query. |
Method Summary | |
---|---|
void |
add(BooleanClause clause)
Adds a clause to a boolean query. |
void |
add(Query query,
BooleanClause.Occur occur)
Adds a clause to a boolean query. |
List<BooleanClause> |
clauses()
Returns the list of clauses in this query. |
Object |
clone()
Returns a clone of this query. |
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. |
void |
extractTerms(Set<Term> terms)
Expert: adds all terms occurring in this query to the terms set. |
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 satisfied. |
Similarity |
getSimilarity(Searcher searcher)
Expert: Returns the Similarity implementation to be used for this query. |
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. |
Iterator<BooleanClause> |
iterator()
Returns an iterator on the clauses in this query. |
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 per BooleanQuery. |
void |
setMinimumNumberShouldMatch(int min)
Specifies a minimum number of the optional BooleanClauses which must be satisfied. |
String |
toString(String field)
Prints a user-readable version of this query. |
Methods inherited from class org.apache.lucene.search.Query |
---|
combine, getBoost, mergeBooleanQueries, setBoost, toString, weight |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int minNrShouldMatch
Constructor Detail |
---|
public BooleanQuery()
public BooleanQuery(boolean disableCoord)
Similarity.coord(int,int)
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
.
disableCoord
- disables Similarity.coord(int,int)
in scoring.Method Detail |
---|
public static int getMaxClauseCount()
BooleanQuery.TooManyClauses
to be thrown.
setMaxClauseCount(int)
public static void setMaxClauseCount(int maxClauseCount)
public boolean isCoordDisabled()
Similarity.coord(int,int)
is disabled in
scoring for this query instance.
BooleanQuery(boolean)
public Similarity getSimilarity(Searcher searcher)
Query
getSimilarity
in class Query
public void setMinimumNumberShouldMatch(int min)
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.
min
- the number of optional clauses that must matchpublic int getMinimumNumberShouldMatch()
public void add(Query query, BooleanClause.Occur occur)
BooleanQuery.TooManyClauses
- if the new number of clauses exceeds the maximum clause numbergetMaxClauseCount()
public void add(BooleanClause clause)
BooleanQuery.TooManyClauses
- if the new number of clauses exceeds the maximum clause numbergetMaxClauseCount()
public BooleanClause[] getClauses()
public List<BooleanClause> clauses()
public final Iterator<BooleanClause> iterator()
Iterable
interface to
make it possible to do:
for (BooleanClause clause : booleanQuery) {}
iterator
in interface Iterable<BooleanClause>
public Weight createWeight(Searcher searcher) throws IOException
Query
Only implemented by primitive queries, which re-write to themselves.
createWeight
in class Query
IOException
public Query rewrite(IndexReader reader) throws IOException
Query
rewrite
in class Query
IOException
public void extractTerms(Set<Term> terms)
Query
rewritten
form.
extractTerms
in class Query
public Object clone()
Query
clone
in class Query
public String toString(String field)
toString
in class Query
public boolean equals(Object o)
o
is equal to this.
equals
in class Query
public int hashCode()
hashCode
in class Query
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |