Save This Page
Home » lucene-2.3.2-src » org.apache » lucene » search » [javadoc | source]
org.apache.lucene.search
public class: BooleanQuery [javadoc | source]
java.lang.Object
   org.apache.lucene.search.Query
      org.apache.lucene.search.BooleanQuery

All Implemented Interfaces:
    Cloneable, Serializable

A Query that matches documents matching boolean combinations of other queries, e.g. TermQuery s, PhraseQuery s or other BooleanQuerys.
Nested Class Summary:
public static class  BooleanQuery.TooManyClauses  Thrown when an attempt is made to add more than {@link #getMaxClauseCount()} clauses. This typically happens if a PrefixQuery, FuzzyQuery, WildcardQuery, or RangeQuery is expanded to many terms during search. 
Field Summary
protected  int minNrShouldMatch     
Constructor:
 public BooleanQuery() 
 public BooleanQuery(boolean disableCoord) 
Method from org.apache.lucene.search.BooleanQuery Summary:
add,   add,   clauses,   clone,   createWeight,   equals,   extractTerms,   getAllowDocsOutOfOrder,   getClauses,   getMaxClauseCount,   getMinimumNumberShouldMatch,   getSimilarity,   getUseScorer14,   hashCode,   isCoordDisabled,   rewrite,   setAllowDocsOutOfOrder,   setMaxClauseCount,   setMinimumNumberShouldMatch,   setUseScorer14,   toString
Methods from org.apache.lucene.search.Query:
clone,   combine,   createWeight,   extractTerms,   getBoost,   getSimilarity,   mergeBooleanQueries,   rewrite,   setBoost,   toString,   toString,   weight
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.lucene.search.BooleanQuery Detail:
 public  void add(BooleanClause clause) 
    Adds a clause to a boolean query.
 public  void add(Query query,
    Occur occur) 
    Adds a clause to a boolean query.
 public List clauses() 
    Returns the list of clauses in this query.
 public Object clone() 
 protected Weight createWeight(Searcher searcher) throws IOException 
 public boolean equals(Object o) 
    Returns true iff o is equal to this.
 public  void extractTerms(Set terms) 
 public static boolean getAllowDocsOutOfOrder() 
    Whether hit docs may be collected out of docid order.
 public BooleanClause[] getClauses() 
    Returns the set of clauses in this query.
 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 TooManyClauses to be thrown.
 public int getMinimumNumberShouldMatch() 
    Gets the minimum number of the optional BooleanClauses which must be satisifed.
 public Similarity getSimilarity(Searcher searcher) 
 public static boolean getUseScorer14() 
Deprecated! Use - #getAllowDocsOutOfOrder() instead.

 public int hashCode() 
    Returns a hash code value for this object.
 public boolean isCoordDisabled() 
 public Query rewrite(IndexReader reader) throws IOException 
 public static  void setAllowDocsOutOfOrder(boolean allow) 
    Expert: Indicates whether hit docs may be collected out of docid order.

    Background: although the contract of the Scorer class requires that documents be iterated in order of doc id, this was not true in early versions of Lucene. Many pieces of functionality in the current Lucene code base have undefined behavior if this contract is not upheld, but in some specific simple cases may be faster. (For example: disjunction queries with less than 32 prohibited clauses; This setting has no effect for other queries.)

    Specifics: By setting this option to true, calls to HitCollector#collect(int,float) might be invoked first for docid N and only later for docid N-1. Being static, this setting is system wide.

 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 org.apache.lucene.store.MMapDirectory the buffering is left to the operating system.

 public  void setMinimumNumberShouldMatch(int min) 
    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.

    EXPERT NOTE: Using this method may force collecting docs in order, regardless of whether setAllowDocsOutOfOrder(true) has been called.

 public static  void setUseScorer14(boolean use14) 
Deprecated! Use - #setAllowDocsOutOfOrder(boolean) instead.

 public String toString(String field) 
    Prints a user-readable version of this query.