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

This commit is contained in:
Yuting Gan 2022-04-20 12:56:43 -07:00 committed by GitHub
parent 2d278a0efe
commit ec53a72a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 2 deletions

View File

@ -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
---------------------

View File

@ -109,7 +109,7 @@ abstract class TaxonomyFacets extends Facets {
* @lucene.experimental
*/
public boolean siblingsLoaded() {
return children != null;
return siblings != null;
}
/**

View File

@ -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();