nick-boss-tech opened a new pull request, #5081: URL: https://github.com/apache/solr/pull/5081
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)* https://issues.apache.org/jira/browse/SOLR-7504 ## What happens today **An atomic update on the counted field is counted as one value.** The counter replaces the field's values with their number ([counter](https://github.com/nick-boss-tech/solr/blob/22b77196e662e93aca6ddc926c6738fb69c817fb/solr/core/src/java/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.java#L76-L85)). An atomic update reaches it as a map of operations. The whole map counts as one value, so a `set` of two values counts as 1. ## What this change does **The counter counts a `set` operand. Every other atomic operation on the counted field is rejected.** - A `set` operand counts its elements when it is a collection or an array, duplicates included. A single value counts as 1. A null counts as 0 ([count](https://github.com/nick-boss-tech/solr/blob/22b77196e662e93aca6ddc926c6738fb69c817fb/solr/core/src/java/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.java#L134-L144)). - Several operation maps apply in order, and the last `set` decides the count ([count rule](https://github.com/nick-boss-tech/solr/blob/22b77196e662e93aca6ddc926c6738fb69c817fb/solr/core/src/java/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.java#L88-L132)). - `add`, `remove`, `inc`, `add-distinct` and `removeregex` on the counted field now fail with BAD_REQUEST. Before this change, such a request succeeded and stored a count of 1. This is the one behavior change for existing updates. - A plain value in the same field as an operation map is rejected with BAD_REQUEST. The check reads every value, so a plain value first is rejected too ([scan](https://github.com/nick-boss-tech/solr/blob/22b77196e662e93aca6ddc926c6738fb69c817fb/solr/core/src/java/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.java#L78-L82)). - An operation map with no operation is rejected with BAD_REQUEST. ## Proof **The plain-first test fails on the factory before the fix and passes with this change.** - `FieldMutatingUpdateProcessorTest` 29 of 29 pass with this change. The plain-first test, [`testCountValuesAtomicUpdatePlainValueFirst`](https://github.com/nick-boss-tech/solr/blob/22b77196e662e93aca6ddc926c6738fb69c817fb/solr/core/src/test/org/apache/solr/update/processor/FieldMutatingUpdateProcessorTest.java#L852-L865), fails on the factory before the fix. - `ParsingFieldUpdateProcessorsTest` 42 of 42 pass. - The module check is clean. - Verified 2026-10-09 at this head. ## Limits **Only updates that carry the counted field are covered. The chain placement is unchanged.** - The counter runs only when the source field is in the update. An update that leaves the source field out is not covered. A trailing `DefaultValue` after the counter would then write a plain 0, which an atomic update applies as a `set`. This is a reading of the chain, not a run, and the chain is not changed here. - The changelog title covers only updates that carry the counted field. - The tests call the counter directly. No end-to-end atomic update is run. - SOLR-6045 applies the same rule in `AtomicUpdateDocumentMerger`: a plain value mixed with an operation map is rejected in either order. The two checks sit in different files. - SOLR-7504 lands before SOLR-12705. SOLR-12705 changes the field mutating base class, and the two branches merge without conflicts at their heads. A combined run of this head with SOLR-12705 at [aa56b7b1be4](https://github.com/nick-boss-tech/solr/commit/aa56b7b1be4c5491723c58f296e20c906d7b7334) passed on 2026-10-09: both suites green, 30 of 30 and 43 of 43. SOLR-12705's counting test now pins only the atomic-operand opt-out, not counted-field outcomes, so the rejection above governs counted fields. Changelog: `changelog/unreleased/SOLR-7504-count-values-atomic-update.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]
