nick-boss-tech opened a new pull request, #5144:
URL: https://github.com/apache/solr/pull/5144

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-8088
   
   ## What happens today
   
   **Distributed grouping on a multiValued field is accepted, then fails later 
inside Lucene.**
   
   A distributed grouped query can name a multiValued field, such as `cat` in 
the test schema. The search-phase command builder checks only that its required 
fields are set ([SearchGroupsFieldCommand.java lines 68-74 at the 
merge-base](https://github.com/nick-boss-tech/solr/blob/cabedd1d968059215188f4e7563fb303241899ed/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java#L68-L74)).
 Nothing checks the field type there. The grouping code then reads the field as 
single valued docValues, and the request fails inside Lucene with an 
IllegalStateException about docValues.
   
   ## What this change does
   
   **Grouping on a multiValued field is rejected up front with a 400 error.**
   
   - Both command builders run the same check. The search-phase builder does 
([SearchGroupsFieldCommand.java lines 69-91 at the 
head](https://github.com/nick-boss-tech/solr/blob/567efa9b78c32df3454ed431a40a04c06ed09d46/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java#L69-L91)),
 and so does the second-phase builder ([TopGroupsFieldCommand.java line 
109](https://github.com/nick-boss-tech/solr/blob/567efa9b78c32df3454ed431a40a04c06ed09d46/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java#L109)).
   - For a field named `cat`, the 400 message reads: `Distributed grouping 
requires a single valued field, but 'cat' is multiValued; group on a single 
valued (e.g. copyField) field instead`.
   - Single valued fields are unchanged. The check skips numeric fields ([line 
84](https://github.com/nick-boss-tech/solr/blob/567efa9b78c32df3454ed431a40a04c06ed09d46/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java#L84)).
   
   ## Proof
   
   **A new test fails on the base code and passes with this change.**
   
   - `SearchGroupsFieldCommandTest.testMultiValuedFieldIsRejected` ([test lines 
33-49](https://github.com/nick-boss-tech/solr/blob/567efa9b78c32df3454ed431a40a04c06ed09d46/solr/core/src/test/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommandTest.java#L33-L49))
 builds the command for a multiValued field and expects a 400 error. On the 
base code the builder returns normally, so the expected error never comes.
   - Verified 2026-10-09 at head 567efa9b78c3: SearchGroupsFieldCommandTest 2 
of 2. On the base code, with this test in place, the class runs 2 tests and one 
fails: this test.
   
   ## Limits
   
   **Numeric multiValued fields are not checked, and no test runs a distributed 
query end to end.**
   
   - Both tests call the builder directly. Neither sends a query.
   - Grouping on a multiValued field that works end to end is a larger change, 
and it is not made here. I can open a follow-up ticket and PR for it on request.
   
   Changelog: 
[changelog/unreleased/SOLR-8088-grouping-multivalued.yml](https://github.com/nick-boss-tech/solr/blob/567efa9b78c32df3454ed431a40a04c06ed09d46/changelog/unreleased/SOLR-8088-grouping-multivalued.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]

Reply via email to