elangelo opened a new pull request, #5250: URL: https://github.com/apache/solr/pull/5250
https://issues.apache.org/jira/browse/SOLR-18597 # Description In a distributed request, a terms facet with `prefix` and `numBuckets:true` on a multi-valued field also counts the values without the prefix: the shard restricts the domain to the docs that have a value with the prefix, and then puts all values of those docs in the HLL. # Solution `calculateNumBuckets` passes the prefix to the `UniqueSlotAcc` it creates, and `getShardHLL` skips the values that do not start with it. The values are already looked up there to be hashed, so the cost is a byte comparison per value. Numeric fields do not accept a prefix, so only `UniqueSlotAcc` needs it. This change was written with the help of an AI coding assistant (Claude Code) and reviewed by me. # Tests `TestJsonFacets.doStats` gets a `prefix` + `numBuckets` case on `multi_ss`. Without the fix, `testStatsDistrib` fails with `mismatch: '1'!='2' @ facets/f1/numBuckets` (checked with the DV, UIF and STREAM methods); with the fix it passes for all six facet methods, and `testStats` passes before and after. The tests in `org.apache.solr.search.facet` pass, and `./gradlew check -x test` passes. We also run the fix backported to 9.11.0 on a 3-shard collection with our full test data set: every distinct count of our hierarchy facets (multi-valued path fields faceted per level with a prefix) now matches a single core, where the unpatched 9.11.0 returned, for example, 350,131 instead of 61. # Checklist - [x] I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability. - [x] I have created a Jira issue and added the issue ID to my pull request title. - [ x] I have given Solr maintainers access to contribute to my PR branch. - [x] I have developed this patch against the `main` branch. - [ x] I have run `./gradlew check`. - [x] I have added tests for my changes. - [ ] I have added documentation for the Reference Guide - [x] I have added a changelog entry for my change -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
