lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r776805 - in /lucene/java/trunk/src/java/org/apache/lucene/search: MultiTermQuery.java RangeQuery.java
Date Wed, 20 May 2009 18:46:55 GMT
Author: mikemccand
Date: Wed May 20 18:46:55 2009
New Revision: 776805

URL: http://svn.apache.org/viewvc?rev=776805&view=rev
Log:
clarify constantScoreRewrite for MultiTermQuery/RangeQuery

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQuery.java?rev=776805&r1=776804&r2=776805&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQuery.java Wed May 20 18:46:55
2009
@@ -22,21 +22,29 @@
 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.
- * <P>
- * <code>MultiTermQuery</code> is not designed to be used by itself. <BR>
- * The reason being that it is not intialized with a {@link FilteredTermEnum}
- * enumeration. A {@link FilteredTermEnum} enumeration needs to be provided.
- * <P>
- * For example, {@link WildcardQuery} and {@link FuzzyQuery} extend
- * <code>MultiTermQuery</code> 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.
+ *
+ * <p>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.
+ *
+ * <p><b>NOTE</b>: 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 @@
     return buffer.toString();
   }
 
+  /**
+   * @see #setConstantScoreRewrite
+   */
   public boolean getConstantScoreRewrite() {
     return constantScoreRewrite;
   }
 
+  /**
+   * This method determines what method is used during searching:
+   * <ul>
+   *
+   *   <li> When constantScoreRewrite is <code>false</code>
+   *   (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.
+   *
+   *   <li> When constantScoreRewrite is <code>true</code>,
+   *   the query is first rewritten to a filter.  Matching
+   *   documents will identical scores, equal to this
+   *   query's boost.
+   * </ul>
+   */
   public void setConstantScoreRewrite(boolean constantScoreRewrite) {
     this.constantScoreRewrite = constantScoreRewrite;
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java?rev=776805&r1=776804&r2=776805&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/RangeQuery.java Wed May 20 18:46:55
2009
@@ -24,19 +24,12 @@
 import org.apache.lucene.index.IndexReader;
 
 /**
- * A Query that matches documents within an exclusive range. A RangeQuery
- * is built by QueryParser for input like <code>[010 TO 120]</code> 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:
- * <ul>
- *  <li>In certain situations, it may be faster than the standard RangeQuery mode</li>
- *  <li>Unlike the RangeQuery mode, it does not cause a BooleanQuery.TooManyClauses
exception if the range of values is large</li>
- *  <li>Unlike the RangeQuery mode, it does not influence scoring based on the scarcity
of individual terms that may match</li>
- * </ul>
- * 
+ * 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;



Mime
View raw message