LUCENE-10047: Fix value de-duping check in LongValueFacetCounts and RangeFacetCounts (#237)

This commit is contained in:
Greg Miller 2021-08-07 10:20:49 -07:00 committed by GitHub
parent e937e739f3
commit a11457b4e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -281,6 +281,9 @@ Bug fixes
* LUCENE-9823: Prevent unsafe rewrites for SynonymQuery and CombinedFieldQuery. Before, rewriting * LUCENE-9823: Prevent unsafe rewrites for SynonymQuery and CombinedFieldQuery. Before, rewriting
could slightly change the scoring when weights were specified. (Naoto Minami via Julie Tibshirani) could slightly change the scoring when weights were specified. (Naoto Minami via Julie Tibshirani)
* LUCENE-10047: Fix a value de-duping bug in LongValueFacetCounts and RangeFacetCounts
(Greg Miller)
Changes in Backwards Compatibility Policy Changes in Backwards Compatibility Policy
* LUCENE-9904: regenerated UAX29URLEmailTokenizer and the corresponding analyzer with up-to-date top * LUCENE-9904: regenerated UAX29URLEmailTokenizer and the corresponding analyzer with up-to-date top

View File

@ -162,11 +162,11 @@ public class LongValueFacetCounts extends Facets {
if (limit > 0) { if (limit > 0) {
totCount++; totCount++;
} }
long previousValue = -1; long previousValue = 0;
for (int i = 0; i < limit; i++) { for (int i = 0; i < limit; i++) {
long value = multiValues.nextValue(); long value = multiValues.nextValue();
// do not increment the count for duplicate values // do not increment the count for duplicate values
if (value != previousValue) { if (i == 0 || value != previousValue) {
increment(value); increment(value);
previousValue = value; previousValue = value;
} }
@ -214,11 +214,11 @@ public class LongValueFacetCounts extends Facets {
if (limit > 0) { if (limit > 0) {
totCount++; totCount++;
} }
long previousValue = -1; long previousValue = 0;
for (int i = 0; i < limit; i++) { for (int i = 0; i < limit; i++) {
long value = multiValues.nextValue(); long value = multiValues.nextValue();
// do not increment the count for duplicate values // do not increment the count for duplicate values
if (value != previousValue) { if (i == 0 || value != previousValue) {
increment(value); increment(value);
previousValue = value; previousValue = value;
} }

View File

@ -193,10 +193,10 @@ abstract class RangeFacetCounts extends Facets {
totCount++; totCount++;
} else { } else {
counter.startMultiValuedDoc(); counter.startMultiValuedDoc();
long previous = -1; long previous = 0;
for (int j = 0; j < limit; j++) { for (int j = 0; j < limit; j++) {
long val = mapDocValue(multiValues.nextValue()); long val = mapDocValue(multiValues.nextValue());
if (val != previous) { if (j == 0 || val != previous) {
counter.addMultiValued(val); counter.addMultiValued(val);
previous = val; previous = val;
} }