diff --git a/src/java/org/apache/lucene/search/MultiTermQuery.java b/src/java/org/apache/lucene/search/MultiTermQuery.java index 651a101d925..36ff38406d9 100644 --- a/src/java/org/apache/lucene/search/MultiTermQuery.java +++ b/src/java/org/apache/lucene/search/MultiTermQuery.java @@ -22,21 +22,29 @@ import java.io.IOException; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.util.ToStringUtils; +import org.apache.lucene.queryParser.QueryParser; // for javadoc /** - * A {@link Query} that matches documents containing a subset of terms provided - * by a {@link FilteredTermEnum} enumeration. - *

- * MultiTermQuery is not designed to be used by itself.
- * The reason being that it is not intialized with a {@link FilteredTermEnum} - * enumeration. A {@link FilteredTermEnum} enumeration needs to be provided. - *

- * For example, {@link WildcardQuery} and {@link FuzzyQuery} extend - * MultiTermQuery to provide {@link WildcardTermEnum} and - * {@link FuzzyTermEnum}, respectively. - * - * The pattern Term may be null. A query that uses a null pattern Term should - * override equals and hashcode. + * An abstract {@link Query} that matches documents + * containing a subset of terms provided by a {@link + * FilteredTermEnum} enumeration. + * + *

This query cannot be used directly; you must subclass + * it and define {@link #getEnum} to provide a {@link + * FilteredTermEnum} that iterates through the terms to be + * matched. + * + *

NOTE: if {@link #setConstantScoreRewrite} is + * false, you may encounter a {@link + * BooleanQuery.TooManyClauses} exception during searching, + * which happens when the number of terms to be searched + * exceeds {@link BooleanQuery#getMaxClauseCount()}. + * Setting {@link #setConstantScoreRewrite} to false + * prevents this. + * + * Note that {@link QueryParser} by default produces + * MultiTermQueries with {@link #setConstantScoreRewrite} + * true. */ public abstract class MultiTermQuery extends Query { /* @deprecated move to sub class */ @@ -146,10 +154,33 @@ public abstract class MultiTermQuery extends Query { return buffer.toString(); } + /** + * @see #setConstantScoreRewrite + */ public boolean getConstantScoreRewrite() { return constantScoreRewrite; } + /** + * This method determines what method is used during searching: + *

+ */ public void setConstantScoreRewrite(boolean constantScoreRewrite) { this.constantScoreRewrite = constantScoreRewrite; } diff --git a/src/java/org/apache/lucene/search/RangeQuery.java b/src/java/org/apache/lucene/search/RangeQuery.java index dc74e017132..a29fbaa5ec7 100644 --- a/src/java/org/apache/lucene/search/RangeQuery.java +++ b/src/java/org/apache/lucene/search/RangeQuery.java @@ -24,19 +24,12 @@ import org.apache.lucene.index.Term; import org.apache.lucene.index.IndexReader; /** - * A Query that matches documents within an exclusive range. A RangeQuery - * is built by QueryParser for input like [010 TO 120] but only if the QueryParser has - * the useOldRangeQuery property set to true. The QueryParser default behaviour is to use - * the newer ConstantScore mode. This is generally preferable because: - * - * + * A Query that matches documents within an exclusive range. * - * @version $Id$ + * See {@link MultiTermQuery#setConstantScoreRewrite} for the tradeoffs between + * enabling and disabling constantScoreRewrite mode. */ + public class RangeQuery extends MultiTermQuery { private Term lowerTerm; private Term upperTerm;