Skip to content

SOLR-18335 : SPLITSHARD fails to migrate documents when using a numeric PointField as router.field - #4717

Draft
olivierboudet wants to merge 1 commit into
apache:mainfrom
olivierboudet:jira/SOLR-18335-splitshard-router-field-point-field
Draft

SOLR-18335 : SPLITSHARD fails to migrate documents when using a numeric PointField as router.field#4717
olivierboudet wants to merge 1 commit into
apache:mainfrom
olivierboudet:jira/SOLR-18335-splitshard-router-field-point-field

Conversation

@olivierboudet

@olivierboudet olivierboudet commented Aug 6, 2026

Copy link
Copy Markdown

⚠️ 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:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide
  • I have added a changelog entry for my change

Previously, shard splitting could not utilize numeric point fields as router fields. This change introduces the necessary logic to extract routing values from point fields, either via docValues or stored fields, thus expanding the types of fields available for shard splitting.
@olivierboudet
olivierboudet force-pushed the jira/SOLR-18335-splitshard-router-field-point-field branch from 509d181 to f5f7b5c Compare August 6, 2026 20:11
@dsmiley
dsmiley self-requested a review August 6, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant