lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From busc...@apache.org
Subject svn commit: r617963 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/search/BooleanQuery.java src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
Date Sun, 03 Feb 2008 08:21:28 GMT
Author: buschmi
Date: Sun Feb  3 00:21:16 2008
New Revision: 617963

URL: http://svn.apache.org/viewvc?rev=617963&view=rev
Log:
LUCENE-1134: Fixed BooleanQuery.rewrite to only optimze a single clause query if minNumShouldMatch<=0.

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=617963&r1=617962&r2=617963&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sun Feb  3 00:21:16 2008
@@ -22,6 +22,9 @@
 
 Bug fixes
     
+ 1. LUCENE-1134: Fixed BooleanQuery.rewrite to only optimze a single 
+    clause query if minNumShouldMatch<=0. (Shai Erera via Michael Busch)
+	
 New features
 
  1. LUCENE-1137: Added Token.set/getFlags() accessors for passing more information about
a Token through the analysis

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java?rev=617963&r1=617962&r2=617963&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/BooleanQuery.java Sun Feb  3 00:21:16
2008
@@ -363,7 +363,7 @@
   }
 
   public Query rewrite(IndexReader reader) throws IOException {
-    if (clauses.size() == 1) {                    // optimize 1-clause queries
+    if (minNrShouldMatch == 0 && clauses.size() == 1) {                    // optimize
1-clause queries
       BooleanClause c = (BooleanClause)clauses.get(0);
       if (!c.isProhibited()) {			  // just return clause
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java?rev=617963&r1=617962&r2=617963&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java Sun
Feb  3 00:21:16 2008
@@ -284,6 +284,16 @@
         verifyNrHits(q, 0);
     }
 
+    public void testNoOptionalButMin2() throws Exception {
+
+        /* one required, no optional */
+        BooleanQuery q = new BooleanQuery();
+        q.add(new TermQuery(new Term("all", "all" )), BooleanClause.Occur.MUST);//true, 
false);
+
+        q.setMinimumNumberShouldMatch(1); // 1 of 0 optional 
+
+        verifyNrHits(q, 0);
+    }
 
     public void testRandomQueries() throws Exception {
       final Random rnd = new Random(0);



Mime
View raw message