Skip to content

Fix: prevent Solr initialization from clearing index data#185

Merged
mdorf merged 1 commit into
developmentfrom
fix/solr-init-preserve-index-data
May 27, 2026
Merged

Fix: prevent Solr initialization from clearing index data#185
mdorf merged 1 commit into
developmentfrom
fix/solr-init-preserve-index-data

Conversation

@mdorf
Copy link
Copy Markdown
Member

@mdorf mdorf commented May 26, 2026

Summary

Prevent Solr connector initialization from clearing existing index documents as a side effect of force: true.

Changes

  • Update Solr schema initialization so it does not clear index data by default
  • Add an explicit destructive schema reset path via reset_schema!
  • Preserve existing documents when SolrConnector#init(true) is called
  • Add regression coverage proving forced initialization does not delete indexed documents

Why

force: true was used by callers to refresh/reinitialize Solr connections and schema state. Before this change, that path called init_schema, which unconditionally cleared all documents from the resolved Solr collection.

For alias-backed search collections, this could wipe the physical collection behind an alias during routine indexing workflows.

Verification

Added regression coverage in test/solr/test_solr.rb:

  • test_force_init_preserves_existing_documents indexes a document, calls SolrConnector#init(true), and asserts the document remains in the collection.

Targeted test run:

bundle exec rake test TEST="./test/solr/test_solr.rb" TESTOPTS="--verbose --name=test_force_init_preserves_existing_documents"

@mdorf mdorf merged commit 28329ce into development May 27, 2026
10 checks passed
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