LUCENE-10500: StringValueFacetCounts to not rely on sequential collection (#788)

StringValueFacetCounts should use the segment ordinal instead of the current index when looping through the matching hits, as when search is multi-threaded the order of the matching hits (one per segment) is not deterministic.
This commit is contained in:
Luca Cavanna 2022-04-05 22:42:06 +02:00 committed by GitHub
parent 6062ba0b3b
commit 796a19b457
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -279,10 +279,7 @@ public class StringValueFacetCounts extends Facets {
// should all ladder up to the same top-level reader:
validateState(matchingDocs.get(0).context);
for (int i = 0; i < matchingDocs.size(); i++) {
FacetsCollector.MatchingDocs hits = matchingDocs.get(i);
for (FacetsCollector.MatchingDocs hits : matchingDocs) {
// Assuming the state is valid, ordinalMap should be non-null and docValues should be
// a MultiSortedSetDocValues since we have more than one segment:
assert ordinalMap != null;
@ -291,7 +288,7 @@ public class StringValueFacetCounts extends Facets {
MultiDocValues.MultiSortedSetDocValues multiValues =
(MultiDocValues.MultiSortedSetDocValues) docValues;
countOneSegment(multiValues.values[i], hits.context.ord, hits, null);
countOneSegment(multiValues.values[hits.context.ord], hits.context.ord, hits, null);
}
}
}