lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject svn commit: r1673122 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/CHANGES.txt lucene/core/ lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
Date Mon, 13 Apr 2015 07:02:47 GMT
Author: jpountz
Date: Mon Apr 13 07:02:46 2015
New Revision: 1673122

URL: http://svn.apache.org/r1673122
Log:
LUCENE-6416: BooleanQuery.extractTerms now only extracts terms from scoring clauses.

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/lucene/core/   (props changed)
    lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java

Modified: lucene/dev/branches/branch_5x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/CHANGES.txt?rev=1673122&r1=1673121&r2=1673122&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/lucene/CHANGES.txt Mon Apr 13 07:02:46 2015
@@ -56,6 +56,9 @@ Bug Fixes
 * LUCENE-6415: TermsQuery.extractTerms is a no-op (used to throw an
   UnsupportedOperationException). (Adrien Grand)
 
+* LUCENE-6416: BooleanQuery.extractTerms now only extracts terms from scoring
+  clauses. (Adrien Grand)
+
 API Changes
 
 * LUCENE-6377: SearcherFactory#newSearcher now accepts the previous reader

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java?rev=1673122&r1=1673121&r2=1673122&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java
Mon Apr 13 07:02:46 2015
@@ -237,7 +237,7 @@ public class BooleanQuery extends Query
   @Override
   public void extractTerms(Set<Term> terms) {
     for (BooleanClause clause : clauses) {
-      if (clause.isProhibited() == false) {
+      if (clause.isScoring()) {
         clause.getQuery().extractTerms(terms);
       }
     }

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java?rev=1673122&r1=1673121&r2=1673122&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java
Mon Apr 13 07:02:46 2015
@@ -21,7 +21,9 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.BitSet;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
@@ -755,4 +757,19 @@ public class TestBooleanQuery extends Lu
     bq.add(new TermQuery(new Term("field", "d")), Occur.FILTER);
     assertEquals("a +b -c #d", bq.toString("field"));
   }
+
+  public void testExtractTerms() {
+    Term a = new Term("f", "a");
+    Term b = new Term("f", "b");
+    Term c = new Term("f", "c");
+    Term d = new Term("f", "d");
+    BooleanQuery bq = new BooleanQuery();
+    bq.add(new TermQuery(a), Occur.SHOULD);
+    bq.add(new TermQuery(b), Occur.MUST);
+    bq.add(new TermQuery(c), Occur.FILTER);
+    bq.add(new TermQuery(d), Occur.MUST_NOT);
+    Set<Term> terms = new HashSet<>();
+    bq.extractTerms(terms);
+    assertEquals(new HashSet<>(Arrays.asList(a, b)), terms);
+  }
 }



Mime
View raw message