You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by pa...@apache.org on 2022/04/20 22:02:40 UTC

[lucene] branch branch_9x updated: LUCENE-10495: Fix return statement of siblingsLoaded() in TaxonomyFacets (#825)

This is an automated email from the ASF dual-hosted git repository.

patrickz pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new f02061f8053 LUCENE-10495: Fix return statement of siblingsLoaded() in TaxonomyFacets (#825)
f02061f8053 is described below

commit f02061f80533d7d1a3c5306ce9e21125475e3ef1
Author: Yuting Gan <44...@users.noreply.github.com>
AuthorDate: Wed Apr 20 15:02:34 2022 -0700

    LUCENE-10495: Fix return statement of siblingsLoaded() in TaxonomyFacets (#825)
---
 lucene/CHANGES.txt                                 |  4 +-
 .../lucene/facet/taxonomy/TaxonomyFacets.java      |  2 +-
 .../taxonomy/TestTaxonomyFacetValueSource.java     | 50 ++++++++++++++++++++++
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 61bdc47205d..95e03fb8449 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -80,7 +80,9 @@ Bug Fixes
 * LUCENE-10508: Fixes some edge cases where GeoArea were built in a way that vertical planes
   could not evaluate their sign, either because the planes where the same or the center between those
   planes was lying in one of the planes. (Ignacio Vera)
-  
+
+* LUCENE-10495: Fix return statement of siblingsLoaded() in TaxonomyFacets. (Yuting Gan)
+
 Build
 ---------------------
 
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacets.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacets.java
index 3a437e94d03..48bd8ccc695 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacets.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacets.java
@@ -118,7 +118,7 @@ public abstract class TaxonomyFacets extends Facets {
    * @lucene.experimental
    */
   public boolean siblingsLoaded() {
-    return children != null;
+    return siblings != null;
   }
 
   /**
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetValueSource.java b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetValueSource.java
index 4c513dabf5e..3aef1a16950 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetValueSource.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetValueSource.java
@@ -549,6 +549,56 @@ public class TestTaxonomyFacetValueSource extends FacetTestCase {
     IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
   }
 
+  // LUCENE-10495
+  public void testSiblingsLoaded() throws Exception {
+    Directory indexDir = newDirectory();
+    Directory taxoDir = newDirectory();
+
+    DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
+    IndexWriter iw = new IndexWriter(indexDir, newIndexWriterConfig(new MockAnalyzer(random())));
+    FacetsConfig config = new FacetsConfig();
+
+    config.setHierarchical("a", true);
+    config.setMultiValued("a", true);
+    config.setRequireDimCount("a", true);
+
+    Document doc = new Document();
+    doc.add(new FacetField("a", Integer.toString(2), "1"));
+    iw.addDocument(config.build(taxoWriter, doc));
+
+    DirectoryReader r = DirectoryReader.open(iw);
+    DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
+
+    FacetsCollector sfc =
+        newSearcher(r).search(new MatchAllDocsQuery(), new FacetsCollectorManager());
+
+    // Test MAX:
+    Facets facets =
+        new TaxonomyFacetFloatAssociations(
+            taxoReader,
+            config,
+            sfc,
+            AssociationAggregationFunction.MAX,
+            DoubleValuesSource.fromLongField("price"));
+
+    assertTrue(((TaxonomyFacets) facets).childrenLoaded());
+    assertFalse(((TaxonomyFacets) facets).siblingsLoaded());
+
+    // Test SUM:
+    facets =
+        new TaxonomyFacetFloatAssociations(
+            taxoReader,
+            config,
+            sfc,
+            AssociationAggregationFunction.SUM,
+            DoubleValuesSource.fromLongField("price"));
+    assertTrue(((TaxonomyFacets) facets).childrenLoaded());
+    assertFalse(((TaxonomyFacets) facets).siblingsLoaded());
+
+    iw.close();
+    IOUtils.close(taxoWriter, taxoReader, taxoDir, r, indexDir);
+  }
+
   public void testCountAndSumScore() throws Exception {
     Directory indexDir = newDirectory();
     Directory taxoDir = newDirectory();