olivierboudet opened a new pull request, #4717:
URL: https://github.com/apache/solr/pull/4717

   ⚠️ **Please note: This code is 100% raw AI output. I don't have the 
background in Solr internals to review or improve it, so I'm leaving it as a 
Draft for the maintainers to inspect.**
   
   https://issues.apache.org/jira/browse/SOLR-18335
   
   # Description
   
   When executing a SPLITSHARD operation on a collection configured with a 
custom router.field backed by a numeric PointField (e.g. plong), the operation 
completes with status: 0 but existing documents are not migrated to the new 
sub-shards.
   Sub-shards are created and set to ACTIVE, but remain empty. The parent shard 
is marked INACTIVE with all original documents still inside, making them 
unsearchable.
   Collections using the default id field with composite prefix syntax 
(company_id!doc_id) are not affected.
   
   
   # Solution
   
   A dedicated code path splitPointField() is introduced for PointField route 
fields. Instead of term enumeration, it reads the routing value per document 
using:
   * NumericDocValues (primary, most efficient — sequential access)
   * Stored fields as a fallback if docValues are not available
   
   The routing hash is then computed from this value using 
HashBasedRouter.sliceHash(), consistent with how documents were originally 
routed at index time.
   An explicit error is thrown if a point-based router.field exposes neither 
docValues nor stored values, rather than silently producing empty sub-shards.
   
   **This implementation and the associated tests were fully generated with AI 
assistance, and then validated through the external reproducer.**
   
   # Tests
   
   In addition to the automated Solr tests, I also validated the fix against 
the minimal external reproducer shared in the bug report:
   
   https://github.com/olivierboudet/solr-splitshard-test/tree/main
   
   With the patch applied, `SPLITSHARD` no longer completes with empty 
sub-shards when the collection uses a custom numeric `router.field`. Existing 
documents are correctly redistributed into the new active sub-shards and remain 
searchable after the split.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [x] I have reviewed the guidelines for [How to 
Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my 
code conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request 
title.
   - [ ] I have given Solr maintainers 
[access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork)
 to contribute to my PR branch. (optional but recommended, not available for 
branches on forks living under an organisation)
   - [x] I have developed this patch against the `main` branch.
   - [x] I have run `./gradlew check`.
   - [x] I have added tests for my changes.
   - [ ] I have added documentation for the [Reference 
Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   - [x] I have added a [changelog 
entry](https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc) for my 
change
   


-- 
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