lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dor...@apache.org
Subject svn commit: r607606 - in /lucene/java/trunk: CHANGES.txt contrib/miscellaneous/src/java/org/apache/lucene/misc/ChainedFilter.java contrib/miscellaneous/src/test/org/apache/lucene/misc/ChainedFilterTest.java
Date Sun, 30 Dec 2007 22:48:00 GMT
Author: doronc
Date: Sun Dec 30 14:47:59 2007
New Revision: 607606

URL: http://svn.apache.org/viewvc?rev=607606&view=rev
Log:
LUCENE-749: ChainedFilter behavior fixed when logic of first filter is ANDNOT.

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/ChainedFilter.java
    lucene/java/trunk/contrib/miscellaneous/src/test/org/apache/lucene/misc/ChainedFilterTest.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=607606&r1=607605&r2=607606&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sun Dec 30 14:47:59 2007
@@ -207,6 +207,9 @@
   this flag to true fixes the problem.  This flag is a temporary fix and is already
   marked as being deprecated.  3.x will implement the correct approach.  (Shai Erera via
Grant Ingersoll)
     
+28. LUCENE-749: ChainedFilter behavior fixed when logic of 
+    first filter is ANDNOT.  (Antonio Bruno via Doron Cohen)
+    
     
 New features
 

Modified: lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/ChainedFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/ChainedFilter.java?rev=607606&r1=607605&r2=607606&view=diff
==============================================================================
--- lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/ChainedFilter.java
(original)
+++ lucene/java/trunk/contrib/miscellaneous/src/java/org/apache/lucene/misc/ChainedFilter.java
Sun Dec 30 14:47:59 2007
@@ -177,6 +177,12 @@
             result = (BitSet) chain[i].bits(reader).clone();
             ++i;
         }
+        else if (logic == ANDNOT)
+        {
+            result = (BitSet) chain[i].bits(reader).clone();
+            result.flip(0,reader.maxDoc());
+            ++i;
+        }
         else
         {
             result = new BitSet(reader.maxDoc());
@@ -210,6 +216,12 @@
         if (logic[0] == AND)
         {
             result = (BitSet) chain[i].bits(reader).clone();
+            ++i;
+        }
+        else if (logic[0] == ANDNOT)
+        {
+            result = (BitSet) chain[i].bits(reader).clone();
+            result.flip(0,reader.maxDoc());
             ++i;
         }
         else

Modified: lucene/java/trunk/contrib/miscellaneous/src/test/org/apache/lucene/misc/ChainedFilterTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/miscellaneous/src/test/org/apache/lucene/misc/ChainedFilterTest.java?rev=607606&r1=607605&r2=607606&view=diff
==============================================================================
--- lucene/java/trunk/contrib/miscellaneous/src/test/org/apache/lucene/misc/ChainedFilterTest.java
(original)
+++ lucene/java/trunk/contrib/miscellaneous/src/test/org/apache/lucene/misc/ChainedFilterTest.java
Sun Dec 30 14:47:59 2007
@@ -90,6 +90,16 @@
     chain = new ChainedFilter(new Filter[] {bobFilter});
     hits = searcher.search(query, chain);
     assertEquals(MAX / 2, hits.length());
+    
+    chain = new ChainedFilter(new Filter[] {bobFilter}, new int[] {ChainedFilter.AND});
+    hits = searcher.search(query, chain);
+    assertEquals(MAX / 2, hits.length());
+    assertEquals("bob", hits.doc(0).get("owner"));
+    
+    chain = new ChainedFilter(new Filter[] {bobFilter}, new int[] {ChainedFilter.ANDNOT});
+    hits = searcher.search(query, chain);
+    assertEquals(MAX / 2, hits.length());
+    assertEquals("sue", hits.doc(0).get("owner"));
   }
 
   public void testOR() throws Exception {
@@ -127,6 +137,15 @@
     assertEquals("ANDNOT matches just bob",
         MAX / 2, hits.length());
     assertEquals("bob", hits.doc(0).get("owner"));
+    
+    chain = new ChainedFilter(
+        new Filter[]{bobFilter, bobFilter},
+          new int[] {ChainedFilter.ANDNOT, ChainedFilter.ANDNOT});
+
+      hits = searcher.search(query, chain);
+      assertEquals("ANDNOT bob ANDNOT bob matches all sues",
+          MAX / 2, hits.length());
+      assertEquals("sue", hits.doc(0).get("owner"));
   }
 
   private Date parseDate(String s) throws ParseException {



Mime
View raw message