Skip to content

Apache Lucene open-source search software

LUCENE-10495: Fix return statement of siblingsLoaded() in TaxonomyFacets (#778)

Yuting Ganec53a72a445f
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index d3f3c4da1d5..fef1ec97da4 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -137,7 +137,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 5e80485c86a..e95acb037b8 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
@@ -109,7 +109,7 @@ 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 34cc0da5ebe..3e5689e7815 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
@@ -501,6 +501,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();