nick-boss-tech opened a new pull request, #5140: URL: https://github.com/apache/solr/pull/5140
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)* https://issues.apache.org/jira/browse/SOLR-8003 ## What happens today **A glob cannot take a raw value transformer, so `fl=*_json:[json]` returns a 400 error.** A request such as `fl=*_json:[json]` or `fl=su*:[json]` fails with a 400 "fieldname parse error". The parser accepts a glob only when a space, a comma or the end of the string follows it ([SolrReturnFields.java lines 307-316 at the merge-base](https://github.com/nick-boss-tech/solr/blob/cabedd1d968059215188f4e7563fb303241899ed/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java#L307-L316)). It then gives up on the glob ([lines 332-333 at the merge-base](https://github.com/nick-boss-tech/solr/blob/cabedd1d968059215188f4e7563fb303241899ed/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java#L332-L333)). Today a raw transformer works only on one named field, so writing every `_json` field raw means listing each name. ## What this change does **A glob followed by a raw value transformer now writes each matching field raw.** - `fl=*_json:[json]` and `fl=su*:[json]` are accepted. Each returned field whose name matches is written raw, under its own name ([SolrReturnFields.java lines 318-345 at the head](https://github.com/nick-boss-tech/solr/blob/17c516a607a88e7cf3e2f2af464c4dd6d969c25b/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java#L318-L345)). `*:[json]` sets the all-fields flag, as a bare `*` does. - The response writer checks the marker against each field as it is written ([TextResponseWriter.java lines 122-133](https://github.com/nick-boss-tech/solr/blob/17c516a607a88e7cf3e2f2af464c4dd6d969c25b/solr/core/src/java/org/apache/solr/response/TextResponseWriter.java#L122-L133)). Only the JSON and XML writers do this ([JSONWriter.java line 110](https://github.com/nick-boss-tech/solr/blob/17c516a607a88e7cf3e2f2af464c4dd6d969c25b/solr/core/src/java/org/apache/solr/response/JSONWriter.java#L110), [XMLWriter.java line 192](https://github.com/nick-boss-tech/solr/blob/17c516a607a88e7cf3e2f2af464c4dd6d969c25b/solr/core/src/java/org/apache/solr/response/XMLWriter.java#L192)). Other writers ignore it, as they already ignore `[json]` and `[xml]`. - A glob combined with another transformer, such as `su*:[docid]`, still returns a 400 ([lines 327-334](https://github.com/nick-boss-tech/solr/blob/17c516a607a88e7cf3e2f2af464c4dd6d969c25b/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java#L327-L334)). ## A choice to check **The marker is set on the glob, not on each field.** - Implemented: one glob-level marker, checked against each field name as the field is written. - Alternative: one transformer for each matching field, which the request parser would have to know in advance. A glob can match names that only some documents carry, so the parser cannot know them. - Was a glob-level marker the right call, or should each matching field get its own transformer? ## Proof **A new test fails on the base code and passes with this change.** - `TestRawTransformer.testGlobJsonTransformer` ([test lines 304-363](https://github.com/nick-boss-tech/solr/blob/17c516a607a88e7cf3e2f2af464c4dd6d969c25b/solr/core/src/test/org/apache/solr/response/TestRawTransformer.java#L304-L363)) sends the glob requests above and checks the raw output. On the base code the first request is rejected with a 400, so the test fails there. - Verified 2026-10-09 at head 17c516a607a8: TestRawTransformer 3 of 3. On the base code, with this test in place, the class runs 3 tests and one fails: this test. ## Limits **Only the JSON writer is tested with a glob. Some combinations are not covered.** - Every glob request in the test uses `wt=json`. The XML writer is not tested with a glob. - A glob combined with `renameFields`, and nested child documents, are not tested. Changelog: [changelog/unreleased/SOLR-8003-fl-glob-raw-transformer.yml](https://github.com/nick-boss-tech/solr/blob/17c516a607a88e7cf3e2f2af464c4dd6d969c25b/changelog/unreleased/SOLR-8003-fl-glob-raw-transformer.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]
