You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "serhiy-bzhezytskyy (via GitHub)" <gi...@apache.org> on 2026/07/16 14:58:48 UTC

[PR] SOLR-12239: add RESORTINDEX core-admin action to re-sort an existing index [solr]

serhiy-bzhezytskyy opened a new pull request, #4644:
URL: https://github.com/apache/solr/pull/4644

   https://issues.apache.org/jira/browse/SOLR-12239
   
   Enabling an index sort on an existing collection currently fails on core reload with `IndexWriter`'s `validateIndexSort` ("cannot change previous indexSort") — Lucene rejects the transition from unsorted segments to a configured sort, so today you have to delete and reindex from source.
   
   This adds a `RESORTINDEX` core-admin action that re-sorts the existing index into a target sort order and swaps it in, without reindexing.
   
   **Mechanism** (LUCENE-9484, shipped in Lucene 9.0): each existing segment reader is wrapped in a `SortingCodecReader` and merged into a fresh sort-configured `IndexWriter` via `addIndexes(CodecReader...)`; the result is swapped in with `modifyIndexProps` (the same path RestoreCore/replication use), then the writer and searcher are reopened. Note `addIndexes` does not auto-sort unsorted readers (LUCENE-8505 removed that), so the explicit `SortingCodecReader` wrap is what performs the re-sort.
   
   **Details:**
   - v1 (`action=RESORTINDEX&core=X&sort=...`) and v2 (`POST /api/cores/X/resort`) APIs; v1 delegates to the v2 impl.
   - Target sort is the `sort` param (usual Solr sort syntax), or falls back to the core's configured `SortingMergePolicy` sort if omitted.
   - Not supported in SolrCloud mode.
   - Indexes with child/nested documents are rejected (re-sorting would break the parent-child blocks).
   - The re-sort writer mirrors `SolrIndexConfig`'s parent-field handling so it works on child-doc-capable schemas.
   - Failed swap rolls back to the original index (RestoreCore's pattern).
   - Tests: v1 (happy path, unparseable-sort, no-sort-and-none-configured, child-doc rejection), config-sort fallback, and the v2 API directly. Ref-guide + changelog included.
   
   I see this as the migration piece that complements SOLR-13681 / #313 (making the index sort configurable) — resort an existing index, then declare the matching sort in config so new docs stay sorted. Filing as a PoC/for discussion: does this approach fit with how index sorting should evolve? Happy to adjust. I did not want to step on the config work.


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-12239: add RESORTINDEX core-admin action to re-sort an existing index [solr]

Posted by "serhiy-bzhezytskyy (via GitHub)" <gi...@apache.org>.
serhiy-bzhezytskyy commented on PR #4644:
URL: https://github.com/apache/solr/pull/4644#issuecomment-5165077410

   Closing this. As I said on SOLR-12239, you read it right — I built this because I'd just seen the issue, not because I had a use for it, and your points about SolrCloud, nested docs and the solrconfig.xml step stand.
   
   Nothing here is lost: what I learned from it went into #4648, which lays out the whole index-sorting picture rather than this one ticket. SOLR-12239 stays open with the mechanism written up in the comments, so anyone who does want after-the-fact resorting has the analysis and the LUCENE-9484 answer to start from.
   


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-12239: add RESORTINDEX core-admin action to re-sort an existing index [solr]

Posted by "serhiy-bzhezytskyy (via GitHub)" <gi...@apache.org>.
serhiy-bzhezytskyy closed pull request #4644: SOLR-12239: add RESORTINDEX core-admin action to re-sort an existing index
URL: https://github.com/apache/solr/pull/4644


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org