Skip to content

[8.x] Rare terms aggregation false **positive** fix (#126884) #127358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/126884.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 126884
summary: Rare terms aggregation false **positive** fix
area: Aggregations
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public void merge(SetBackedScalingCuckooFilter other) {
} else if (isSetMode == false && other.isSetMode) {
// Rather than converting the other to a cuckoo first, we can just
// replay the values directly into our filter.
other.hashes.forEach(this::add);
other.hashes.forEach(this::addHash);
} else {
// Both are in cuckoo mode, merge raw fingerprints

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,34 @@ public void testConvertTwice() {
);
}

public void testMergeBigSmall() {
int threshold = 1000;

// Setup the first filter
SetBackedScalingCuckooFilter filter = new SetBackedScalingCuckooFilter(threshold, Randomness.get(), 0.01);
int counter = 0;
Set<Long> values = new HashSet<>();
while (counter < threshold + 1) {
long value = randomLong();
filter.add(value);
boolean newValue = values.add(value);
if (newValue) {
counter += 1;
}
}

SetBackedScalingCuckooFilter filter2 = new SetBackedScalingCuckooFilter(threshold, Randomness.get(), 0.01);
long value = randomLong();
while (filter.mightContain(value)) {
value = randomLong();
}

filter2.add(value);

filter.merge(filter2);
assertTrue(filter.mightContain(value));
}

public void testMergeSmall() {
int threshold = 1000;

Expand Down