lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1465372 - in /lucene/dev/trunk: ./ lucene/ lucene/facet/ lucene/facet/src/java/org/apache/lucene/facet/search/ lucene/facet/src/test/org/apache/lucene/facet/search/
Date Sun, 07 Apr 2013 12:18:23 GMT
Author: mikemccand
Date: Sun Apr  7 12:18:22 2013
New Revision: 1465372

URL: http://svn.apache.org/r1465372
Log:
LUCENE-4913: ordinal was 0 when all children are returned

Modified:
    lucene/dev/trunk/   (props changed)
    lucene/dev/trunk/lucene/   (props changed)
    lucene/dev/trunk/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/trunk/lucene/facet/   (props changed)
    lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/search/FloatFacetResultsHandler.java
    lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/search/IntFacetResultsHandler.java
    lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java
    lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1465372&r1=1465371&r2=1465372&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Sun Apr  7 12:18:22 2013
@@ -229,6 +229,9 @@ Bug Fixes
   flag.  It affects SpatialRecursivePrefixTreeStrategy on non-point indexed
   shapes, as of Lucene 4.2. (David Smiley)
 
+* LUCENE-4913: FacetResultNode.ordinal was always 0 when all children
+  are returned. (Mike McCandless)
+
 Documentation
 
 * LUCENE-4841: Added example SimpleSortedSetFacetsExample to show how

Modified: lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/search/FloatFacetResultsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/search/FloatFacetResultsHandler.java?rev=1465372&r1=1465371&r2=1465372&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/search/FloatFacetResultsHandler.java
(original)
+++ lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/search/FloatFacetResultsHandler.java
Sun Apr  7 12:18:22 2013
@@ -66,9 +66,8 @@ public final class FloatFacetResultsHand
     while (ordinal != TaxonomyReader.INVALID_ORDINAL) {
       float value = values[ordinal];
       if (value > 0) {
-        FacetResultNode node = new FacetResultNode();
+        FacetResultNode node = new FacetResultNode(ordinal, value);
         node.label = taxonomyReader.getPath(ordinal);
-        node.value = value;
         nodes.add(node);
       }
       ordinal = siblings[ordinal];

Modified: lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/search/IntFacetResultsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/search/IntFacetResultsHandler.java?rev=1465372&r1=1465371&r2=1465372&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/search/IntFacetResultsHandler.java
(original)
+++ lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/search/IntFacetResultsHandler.java
Sun Apr  7 12:18:22 2013
@@ -65,9 +65,8 @@ public final class IntFacetResultsHandle
     while (ordinal != TaxonomyReader.INVALID_ORDINAL) {
       int value = values[ordinal];
       if (value > 0) {
-        FacetResultNode node = new FacetResultNode();
+        FacetResultNode node = new FacetResultNode(ordinal, value);
         node.label = taxonomyReader.getPath(ordinal);
-        node.value = value;
         nodes.add(node);
       }
       ordinal = siblings[ordinal];

Modified: lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java?rev=1465372&r1=1465371&r2=1465372&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java
(original)
+++ lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java
Sun Apr  7 12:18:22 2013
@@ -203,7 +203,7 @@ public class TestDemoFacets extends Face
     FacetSearchParams fsp = new FacetSearchParams(fip,
                                                   new CountFacetRequest(new CategoryPath("a",
'/'), 10));
 
-    // Aggregatses the facet counts:
+    // Aggregate the facet counts:
     FacetsCollector c = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
 
     // MatchAllDocsQuery is for "browsing" (counts facets
@@ -215,6 +215,11 @@ public class TestDemoFacets extends Face
     assertEquals(1, results.size());
     assertEquals(1, (int) results.get(0).getFacetResultNode().value);
 
+    // LUCENE-4913:
+    for(FacetResultNode childNode : results.get(0).getFacetResultNode().subResults) {
+      assertTrue(childNode.ordinal != 0);
+    }
+
     searcher.getIndexReader().close();
     taxoReader.close();
     dir.close();

Modified: lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java?rev=1465372&r1=1465371&r2=1465372&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java
(original)
+++ lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java
Sun Apr  7 12:18:22 2013
@@ -304,4 +304,49 @@ public class TestFacetsCollector extends
     IOUtils.close(taxo, taxoDir, r, indexDir);
   }
   
+  @Test
+  public void testParentOrdinal() throws Exception {
+    // LUCENE-4913: root ordinal was always 0 when all children were requested
+    Directory indexDir = newDirectory();
+    Directory taxoDir = newDirectory();
+    
+    TaxonomyWriter taxonomyWriter = new DirectoryTaxonomyWriter(taxoDir);
+    IndexWriter iw = new IndexWriter(indexDir, newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(random())));
+    
+    FacetFields facetFields = new FacetFields(taxonomyWriter);
+    Document doc = new Document();
+    facetFields.addFields(doc, Arrays.asList(new CategoryPath("a/1", '/')));
+    iw.addDocument(doc);
+    taxonomyWriter.close();
+    iw.close();
+    
+    DirectoryReader r = DirectoryReader.open(indexDir);
+    DirectoryTaxonomyReader taxo = new DirectoryTaxonomyReader(taxoDir);
+
+    // assert IntFacetResultHandler
+    FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("a"),
10));
+    FacetsAccumulator fa = random().nextBoolean() ? new FacetsAccumulator(fsp, r, taxo) :
new StandardFacetsAccumulator(fsp, r, taxo);
+    FacetsCollector fc = FacetsCollector.create(fa);
+    new IndexSearcher(r).search(new MatchAllDocsQuery(), fc);
+    assertTrue("invalid ordinal for child node: 0", 0 != fc.getFacetResults().get(0).getFacetResultNode().subResults.get(0).ordinal);
+    
+    // assert IntFacetResultHandler
+    fsp = new FacetSearchParams(new SumScoreFacetRequest(new CategoryPath("a"), 10));
+    if (random().nextBoolean()) {
+      fa = new FacetsAccumulator(fsp, r, taxo) {
+        @Override
+        public FacetsAggregator getAggregator() {
+          return new SumScoreFacetsAggregator();
+        }
+      };
+    } else {
+      fa = new StandardFacetsAccumulator(fsp, r, taxo);
+    }
+    fc = FacetsCollector.create(fa);
+    new IndexSearcher(r).search(new MatchAllDocsQuery(), fc);
+    assertTrue("invalid ordinal for child node: 0", 0 != fc.getFacetResults().get(0).getFacetResultNode().subResults.get(0).ordinal);
+    
+    IOUtils.close(taxo, taxoDir, r, indexDir);
+  }
+  
 }



Mime
View raw message