lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1130606 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g: src/contrib/SimpleFacetedSearch/HitsPerFacet.cs test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs
Date Thu, 02 Jun 2011 15:27:45 GMT
Author: digy
Date: Thu Jun  2 15:27:45 2011
New Revision: 1130606

URL: http://svn.apache.org/viewvc?rev=1130606&view=rev
Log:
[LUCENENET-415] A small bug related with empty query.

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerFacet.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerFacet.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerFacet.cs?rev=1130606&r1=1130605&r2=1130606&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerFacet.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/SimpleFacetedSearch/HitsPerFacet.cs
Thu Jun  2 15:27:45 2011
@@ -59,14 +59,23 @@ namespace Lucene.Net.Search
 
             internal void Calculate()
             {
-                _ResultBitSet = (OpenBitSet)((OpenBitSet)_QueryDocidSet).Clone(); 
-                _ResultBitSet.And(_GroupBitSet);
-
+                if (_QueryDocidSet == DocIdBitSet.EMPTY_DOCIDSET)
+                {
+                    _ResultBitSet = new OpenBitSet(0);
+                }
+                else
+                {
+                    _ResultBitSet = (OpenBitSet)((OpenBitSet)_QueryDocidSet).Clone();
+                    _ResultBitSet.And(_GroupBitSet);
+                }
+                
                 _ResultIterator = _ResultBitSet.Iterator();
 
                 _HitCount = _ResultBitSet.Cardinality();
 
                 _ResultBitSet = null;
+                _QueryDocidSet = null;
+                _GroupBitSet = null;
             }
 
             public FacetName Name

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs?rev=1130606&r1=1130605&r2=1130606&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs
Thu Jun  2 15:27:45 2011
@@ -217,6 +217,22 @@ namespace Lucene.Net.Search
             Assert.AreEqual(0, hits.HitsPerFacet.Length);
         }
 
+        [Test]
+        public void Test7()
+        {
+            Query query = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "text", new
StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)).Parse("a");
+
+            SimpleFacetedSearch sfs = new SimpleFacetedSearch(_Reader, "category");
+            SimpleFacetedSearch.Hits hits = sfs.Search(query);
+
+            Assert.AreEqual(0, hits.TotalHitCount, "Unexpected TotalHitCount");
+            foreach(var x in hits.HitsPerFacet.Where(h=>h.HitCount>0))
+            {
+                Assert.Fail("There must be no hit");
+            }
+            
+        }
+
         int _errorCount = 0;
         void MultiThreadedAccessThread(object o)
         {



Mime
View raw message