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: + *
false
+ * (the default), the query is rewritten to {@link
+ * BooleanQuery} with one clause for each term in the
+ * range. If the the number of terms in the range
+ * exceeds {@link BooleanQuery#getMaxClauseCount()}, a
+ * {@link BooleanQuery.TooManyClauses} exception will be
+ * thrown during searching. This mode may also give
+ * worse performance when the number of terms is large,
+ * and/or the number of matching documents is large.
+ *
+ * true
,
+ * the query is first rewritten to a filter. Matching
+ * documents will identical scores, equal to this
+ * query's boost.
+ * [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:
- *