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

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-16655
   
   ## What happens today
   
   **Field mutating update processors skip child documents, so child fields 
keep the values they were sent with.**
   
   These processors change only the fields of the root document. Child 
documents are skipped, both anonymous children and child documents given as a 
field value. So a trim, regex replace, remove-blank or date parse step does not 
run on a child's field.
   
   ## What this change does
   
   **Child documents given as a field value are changed only under a field the 
selector names. Anonymous child documents are always walked.**
   
   - Under a selected field, each child document in the field value is walked 
at any depth, and the selector decides which of its fields change ([gated 
descent](https://github.com/nick-boss-tech/solr/blob/5e2317443f4116a9e97330b0d6ce175cf44b54df/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java#L128-L145)).
 Under an unselected field, the child is left alone.
   - Anonymous child documents are walked at any depth ([anonymous 
walk](https://github.com/nick-boss-tech/solr/blob/5e2317443f4116a9e97330b0d6ce175cf44b54df/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java#L148-L153)).
 The selector still decides which field names change inside each child.
   - A document reachable by two paths is changed once, since not every 
mutation is safe to repeat ([identity 
check](https://github.com/nick-boss-tech/solr/blob/5e2317443f4116a9e97330b0d6ce175cf44b54df/solr/core/src/java/org/apache/solr/update/processor/FieldMutatingUpdateProcessor.java#L90-L95)).
   - Upgrade note: after upgrading, pipelines that send child documents will 
see these processors change child field values. Examples are trim, regex 
replace, remove-blank and date parsing. Check the chains that send child 
documents before upgrading.
   
   ## Proof
   
   **The focused tests pass at this head, and the new test fails before the 
change.**
   
   - Gate green at `5e2317443f`, recorded 2026-10-09 at 08:03 MDT. From fresh 
JUnit XML: `FieldMutatingUpdateProcessorTest` 36 of 36 and 
`ParsingFieldUpdateProcessorsTest` 44 of 44. `:solr:core:check -x test` exit 
code 0.
   - On the pre-fix head `b201a57fb3e5`, the new test fails. That is the commit 
before this change.
   - `FieldMutatingUpdateProcessorTest` 
[`testTrimFieldsRecurseIntoNestedDocumentsOnlyWhenParentSelected`](https://github.com/nick-boss-tech/solr/blob/5e2317443f4116a9e97330b0d6ce175cf44b54df/solr/core/src/test/org/apache/solr/update/processor/FieldMutatingUpdateProcessorTest.java#L115-L139)
 pins both shapes. A child under an unselected field keeps its values. A child 
under a selected field is trimmed.
   - Other nested tests in that class, such as 
[`testTrimAllRecurseIntoNestedDocuments`](https://github.com/nick-boss-tech/solr/blob/5e2317443f4116a9e97330b0d6ce175cf44b54df/solr/core/src/test/org/apache/solr/update/processor/FieldMutatingUpdateProcessorTest.java#L95-L113),
 check changed values inside child documents.
   - `ParsingFieldUpdateProcessorsTest` 
[`testParseDateNestedLabelledChildDocuments`](https://github.com/nick-boss-tech/solr/blob/5e2317443f4116a9e97330b0d6ce175cf44b54df/solr/core/src/test/org/apache/solr/update/processor/ParsingFieldUpdateProcessorsTest.java#L212-L238)
 checks a parsed date inside a child given as a field value.
   
   ## A choice to check
   
   **The other route leaves anonymous child documents alone, as before.**
   
   Anonymous child documents have no field name for the selector to match. 
Leaving them alone would keep today's output for pipelines that send them. This 
branch walks them instead, and the upgrade note above applies to them.
   
   Was the wider walk into anonymous child documents the right semantics?
   
   ## Limits
   
   **SOLR-16655 lands first, and SOLR-12705 rebases onto it.**
   
   - [SOLR-12705](https://issues.apache.org/jira/browse/SOLR-12705) also 
changes `FieldMutatingUpdateProcessor.java`. This change is confined to the 
child-document descent in `mutateDocument`. SOLR-12705 is the broader atomic 
operands rework in the same file. So this change lands first, and SOLR-12705 
rebases onto it. A merge of the two heads conflicts in that file, and the 
combined tree has not been run. Each change was tested at its own head.
   - The tests run the processor on one document in memory. They do not send an 
update request.
   
   Changelog: 
`changelog/unreleased/SOLR-16655-field-mutating-urps-nested-docs.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