nick-boss-tech opened a new pull request, #5153: URL: https://github.com/apache/solr/pull/5153
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)* https://issues.apache.org/jira/browse/SOLR-10492 ## What happens today **With group.facet=true, distributed facet.field results can show document counts where group counts belong.** The reporter used facet.limit=50 on a SolrCloud collection. The facet.query count was a grouped count of 8, but the facet results showed 233 for the same field, and those were document counts ([JIRA](https://issues.apache.org/jira/browse/SOLR-10492)). When a small facet.limit makes the coordinator refine terms, the listed-term refinement counts each term with `numDocs`, which counts documents, not groups ([SimpleFacets.java, base](https://github.com/nick-boss-tech/solr/blob/e2cdb2d7e8ae0be4cf6cf0606206c67d89e7278f/solr/core/src/java/org/apache/solr/request/SimpleFacets.java#L979)). Those document counts replace the correct grouped counts. ## What this change does **Refinement counts are grouped counts when group.facet=true.** - Listed-term refinement uses the grouped counter for a field with group.facet=true ([SimpleFacets.java L979-L996](https://github.com/nick-boss-tech/solr/blob/ecf21e2192cb91e1ba4a44abce2c43ab8a5409b9/solr/core/src/java/org/apache/solr/request/SimpleFacets.java#L979-L996)). The helper is at [L1005-L1028](https://github.com/nick-boss-tech/solr/blob/ecf21e2192cb91e1ba4a44abce2c43ab8a5409b9/solr/core/src/java/org/apache/solr/request/SimpleFacets.java#L1005-L1028). - A refinement request can arrive with group.field but no grouping specification. The stored-fields shard request removes the group parameter, as it does at the base commit ([StoredFieldsShardRequestFactory.java L66](https://github.com/nick-boss-tech/solr/blob/e2cdb2d7e8ae0be4cf6cf0606206c67d89e7278f/solr/core/src/java/org/apache/solr/search/grouping/distributed/requestfactory/StoredFieldsShardRequestFactory.java#L66)); this change does not touch that file. In that case the counter reads group.field from the request ([L792-L797](https://github.com/nick-boss-tech/solr/blob/ecf21e2192cb91e1ba4a44abce2c43ab8a5409b9/solr/core/src/java/org/apache/solr/request/SimpleFacets.java#L792-L797)). - Behavior change outside distributed refinement: a facet.field request with group.facet=true and group.field, but without group=true, used to fail with BAD_REQUEST. It now returns grouped counts. ## Proof **The new test fails on the base code and passes at this head.** - TestDistributedGrouping 2 of 2 passing at ecf21e2192c, verified 2026-10-05. The new case, with facet.limit 1 and 2 and overrequest off, fails on base e2cdb2d7e8a. The refined term carries a document count where the grouped count is 5. - Other focused classes at this head: TestGroupingSearch 17 of 17, DistributedFacetPivotSmallTest 1 of 1. ## Limits **Distributed refinement is the only path with a test.** - The case described above, a facet.field request without group=true, has no test in this change. - A group.field given only as a local parameter, with group.facet=true and without group=true, still returns BAD_REQUEST for facet.field and facet.query. This change does not change that case. - The cost of the grouped refinement counts on large fields is not measured. Changelog: [`changelog/unreleased/SOLR-10492-group-facet-refinement-counts.yml`](https://github.com/nick-boss-tech/solr/blob/ecf21e2192cb91e1ba4a44abce2c43ab8a5409b9/changelog/unreleased/SOLR-10492-group-facet-refinement-counts.yml) ### AI assistance AI agents assisted with research, implementation, review, and drafting. Nick Shanin directed the work and takes responsibility for this contribution. -- 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]
