mirror of https://github.com/apache/lucene.git
parent
cbec73e4c3
commit
aa040d5230
|
@ -100,6 +100,8 @@ Other
|
|||
Bug Fixes
|
||||
---------------------
|
||||
|
||||
* GITHUB#14008: Counts provided by taxonomy facets in addition to another aggregation are now returned together with
|
||||
their corresponding ordinals. (Paul King)
|
||||
|
||||
======================= Lucene 10.0.0 =======================
|
||||
|
||||
|
@ -399,6 +401,14 @@ Build
|
|||
|
||||
* GITHUB#13698: Upgrade to gradle 8.10 (Dawid Weiss)
|
||||
|
||||
======================== Lucene 9.12.1 =======================
|
||||
|
||||
Bug Fixes
|
||||
---------------------
|
||||
|
||||
* GITHUB#14008: Counts provided by taxonomy facets in addition to another aggregation are now returned together with
|
||||
their corresponding ordinals. (Paul King)
|
||||
|
||||
======================== Lucene 9.12.0 =======================
|
||||
|
||||
Security Fixes
|
||||
|
|
|
@ -314,6 +314,7 @@ abstract class TaxonomyFacets extends Facets {
|
|||
|
||||
LabelAndValue[] labelValues = new LabelAndValue[q.size()];
|
||||
int[] ordinals = new int[labelValues.length];
|
||||
int[] counts = new int[labelValues.length];
|
||||
Number[] values = new Number[labelValues.length];
|
||||
|
||||
for (int i = labelValues.length - 1; i >= 0; i--) {
|
||||
|
@ -321,6 +322,7 @@ abstract class TaxonomyFacets extends Facets {
|
|||
assert ordAndValue != null;
|
||||
ordinals[i] = ordAndValue.ord;
|
||||
values[i] = ordAndValue.getValue();
|
||||
counts[i] = getCount(ordinals[i]);
|
||||
}
|
||||
|
||||
FacetLabel[] bulkPath = taxoReader.getBulkPath(ordinals);
|
||||
|
@ -329,8 +331,7 @@ abstract class TaxonomyFacets extends Facets {
|
|||
int childComponentIdx = path.length + 1;
|
||||
for (int i = 0; i < labelValues.length; i++) {
|
||||
labelValues[i] =
|
||||
new LabelAndValue(
|
||||
bulkPath[i].components[childComponentIdx], values[i], getCount(ordinals[i]));
|
||||
new LabelAndValue(bulkPath[i].components[childComponentIdx], values[i], counts[i]);
|
||||
}
|
||||
|
||||
return new FacetResult(
|
||||
|
|
|
@ -570,6 +570,49 @@ public class TestTaxonomyFacetAssociations extends FacetTestCase {
|
|||
IOUtils.close(taxoReader, reader, taxoDir, dir);
|
||||
}
|
||||
|
||||
public void testAggregationCounts() throws IOException {
|
||||
Directory taxoDir = newDirectory();
|
||||
|
||||
TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
|
||||
|
||||
FacetsConfig config = new FacetsConfig();
|
||||
config.setIndexFieldName("a", "$int_facets");
|
||||
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
|
||||
Document d;
|
||||
|
||||
d = new Document();
|
||||
d.add(new IntAssociationFacetField(1, "a", "1"));
|
||||
writer.addDocument(config.build(taxoWriter, d));
|
||||
|
||||
d = new Document();
|
||||
d.add(new IntAssociationFacetField(5, "a", "2"));
|
||||
writer.addDocument(config.build(taxoWriter, d));
|
||||
|
||||
d = new Document();
|
||||
d.add(new IntAssociationFacetField(1, "a", "1"));
|
||||
writer.addDocument(config.build(taxoWriter, d));
|
||||
|
||||
IndexReader reader = writer.getReader();
|
||||
IOUtils.close(taxoWriter, writer);
|
||||
|
||||
IndexSearcher searcher = newSearcher(reader);
|
||||
Query q = new MatchAllDocsQuery();
|
||||
FacetsCollector fc = searcher.search(q, new FacetsCollectorManager());
|
||||
|
||||
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
|
||||
IntTaxonomyFacets intFacets =
|
||||
new TaxonomyFacetIntAssociations(
|
||||
"$int_facets", taxoReader, config, fc, AssociationAggregationFunction.SUM);
|
||||
|
||||
FacetResult result = intFacets.getTopChildren(10, "a");
|
||||
assertEquals("dim=a path=[] value=7 childCount=2\n 2 (5)\n 1 (2)\n", result.toString());
|
||||
assertEquals(1, result.labelValues[0].count);
|
||||
assertEquals(2, result.labelValues[1].count);
|
||||
|
||||
IOUtils.close(taxoReader, reader, taxoDir);
|
||||
}
|
||||
|
||||
private void validateInts(
|
||||
String dim,
|
||||
Map<String, Integer> expected,
|
||||
|
|
Loading…
Reference in New Issue