lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject svn commit: r1673118 - in /lucene/dev/trunk/lucene: CHANGES.txt queries/src/java/org/apache/lucene/queries/TermsQuery.java
Date Mon, 13 Apr 2015 06:40:38 GMT
Author: jpountz
Date: Mon Apr 13 06:40:38 2015
New Revision: 1673118

URL: http://svn.apache.org/r1673118
Log:
LUCENE-6415: Make TermsQuery.extractTerms a no-op instead of throwing an UOE. 

Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1673118&r1=1673117&r2=1673118&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Mon Apr 13 06:40:38 2015
@@ -82,6 +82,9 @@ Bug Fixes
 * LUCENE-6378: Fix all RuntimeExceptions to throw the underlying root cause.
   (Varun Thacker, Adrien Grand, Mike McCandless)
 
+* LUCENE-6415: TermsQuery.extractTerms is a no-op (used to throw an
+  UnsupportedOperationException). (Adrien Grand)
+
 API Changes
 
 * LUCENE-6377: SearcherFactory#newSearcher now accepts the previous reader

Modified: lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java?rev=1673118&r1=1673117&r2=1673118&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java (original)
+++ lucene/dev/trunk/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java Mon
Apr 13 06:40:38 2015
@@ -24,6 +24,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.lucene.index.Fields;
 import org.apache.lucene.index.LeafReader;
@@ -53,9 +54,21 @@ import org.apache.lucene.util.ToStringUt
  * Specialization for a disjunction over many terms that behaves like a
  * {@link ConstantScoreQuery} over a {@link BooleanQuery} containing only
  * {@link org.apache.lucene.search.BooleanClause.Occur#SHOULD} clauses.
- * This query creates a bit set and sets bits that matches any of the wrapped
- * terms. While this might help performance when there are many terms, it would
- * be slower than a {@link BooleanQuery} when there are few terms to match.
+ * <p>For instance in the following example, both @{code q1} and {@code q2}
+ * would yield the same scores:
+ * <pre class="prettyprint">
+ * Query q1 = new TermsQuery(new Term("field", "foo"), new Term("field", "bar"));
+ * 
+ * BooleanQuery bq = new BooleanQuery();
+ * bq.add(new TermQuery(new Term("field", "foo")), Occur.SHOULD);
+ * bq.add(new TermQuery(new Term("field", "bar")), Occur.SHOULD);
+ * Query q2 = new ConstantScoreQuery(bq);
+ * </pre>
+ * <p>This query creates a bit set and sets bits that match any of the
+ * wrapped terms. While this might help performance when there are many terms,
+ * it would be slower than a {@link BooleanQuery} when there are few terms to
+ * match.
+ * <p>NOTE: This query produces scores that are equal to its boost
  */
 public class TermsQuery extends Query implements Accountable {
 
@@ -249,6 +262,14 @@ public class TermsQuery extends Query im
     return Collections.emptyList();
   }
 
+  @Override
+  public void extractTerms(Set<Term> terms) {
+    // no-op
+    // This query is for abuse cases when the number of terms is too high to
+    // run efficiently as a BooleanQuery. So likewise we hide its terms in
+    // order to protect highlighters
+  }
+
   private static final class TermsAndField implements Accountable {
 
     private static final long BASE_RAM_BYTES_USED =



Mime
View raw message