You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2021/06/06 14:49:13 UTC
[lucene-solr] branch branch_8_9 updated: LUCENE-9991: Address bug
in TestStringValueFacetCounts (#168) (#2505)
This is an automated email from the ASF dual-hosted git repository.
gsmiller pushed a commit to branch branch_8_9
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8_9 by this push:
new f664914 LUCENE-9991: Address bug in TestStringValueFacetCounts (#168) (#2505)
f664914 is described below
commit f66491445ddf871002196849c356af1e237d9119
Author: Greg Miller <gs...@gmail.com>
AuthorDate: Sun Jun 6 07:48:53 2021 -0700
LUCENE-9991: Address bug in TestStringValueFacetCounts (#168) (#2505)
---
lucene/CHANGES.txt | 2 ++
.../lucene/facet/TestStringValueFacetCounts.java | 28 +++++++++++++---------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 59de224..c4c353d 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -89,6 +89,8 @@ Bug Fixes
* LUCEDNE-9967: Do not throw NullPointerException while trying to handle another exception in
ReplicaNode.start (Steven Schlansker)
+* LUCENE-9991: Fix edge case failure in TestStringValueFacetCounts (Greg Miller)
+
Other
---------------------
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/TestStringValueFacetCounts.java b/lucene/facet/src/test/org/apache/lucene/facet/TestStringValueFacetCounts.java
index 2c14830..895bd7a 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/TestStringValueFacetCounts.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/TestStringValueFacetCounts.java
@@ -309,6 +309,22 @@ public class TestStringValueFacetCounts extends FacetTestCase {
FacetResult facetResult = facets.getTopChildren(topN, "field");
+ assertEquals("field", facetResult.dim);
+ assertEquals(0, facetResult.path.length);
+ assertEquals(expectedTotalDocsWithValue, facetResult.value);
+ assertEquals(expectedLabelCount, facetResult.childCount);
+
+ // getAllDims should return a singleton list with the same results as getTopChildren
+ List<FacetResult> allDims = facets.getAllDims(topN);
+ assertEquals(1, allDims.size());
+ assertEquals(facetResult, allDims.get(0));
+
+ // This is a little strange, but we request all labels at this point so that when we
+ // secondarily sort by label value in order to compare to the expected results, we have
+ // all the values. See LUCENE-9991:
+ int maxTopN = expectedCountsSorted.size();
+ facetResult = facets.getTopChildren(maxTopN, "field");
+
// also sort expected labels by count, value (these will be sorted by count, ord -- but since
// we have no insight into the ordinals assigned to the values, we resort)
Arrays.sort(
@@ -321,12 +337,7 @@ public class TestStringValueFacetCounts extends FacetTestCase {
return cmp;
});
- assertEquals("field", facetResult.dim);
- assertEquals(0, facetResult.path.length);
- assertEquals(expectedTotalDocsWithValue, facetResult.value);
- assertEquals(expectedLabelCount, facetResult.childCount);
-
- for (int i = 0; i < Math.min(topN, expectedCountsSorted.size()); i++) {
+ for (int i = 0; i < Math.min(topN, maxTopN); i++) {
String expectedKey = expectedCountsSorted.get(i).getKey();
int expectedValue = expectedCountsSorted.get(i).getValue();
assertEquals(expectedKey, facetResult.labelValues[i].label);
@@ -335,11 +346,6 @@ public class TestStringValueFacetCounts extends FacetTestCase {
assertEquals(expectedValue, facets.getSpecificValue("field", expectedKey));
}
- // getAllDims should return a singleton list with the same results as getTopChildren
- List<FacetResult> allDims = facets.getAllDims(topN);
- assertEquals(1, allDims.size());
- assertEquals(facetResult, allDims.get(0));
-
// execute a "drill down" query on one of the values at random and make sure the total hits
// match the expected count provided by faceting
if (expectedCountsSorted.isEmpty() == false) {