Skip to content

Fix: stale term-search cleanup before reindexing#290

Merged
mdorf merged 1 commit into
developfrom
fix/stale-term-index-cleanup
May 27, 2026
Merged

Fix: stale term-search cleanup before reindexing#290
mdorf merged 1 commit into
developfrom
fix/stale-term-index-cleanup

Conversation

@mdorf
Copy link
Copy Markdown
Member

@mdorf mdorf commented May 26, 2026

Description

Fixes ncbo/ontologies_api#227.

NPDX suggest/autocomplete search was returning stale capitalized classes from an older ontology submission. Selecting those results led to 404s because the class records were no longer present in the latest NPDX submission.

The term indexer was calling the generic Ontology#unindex path before indexing new terms. For ontology records, that path does not perform acronym-scoped class term cleanup, so stale class documents from older submissions could remain in Solr term_search and appear in suggest=true search results.

Changes

  • Use unindex_by_acronym(false) before term reindexing so existing class docs for the ontology acronym are removed from term_search.
  • Use unindex_all_data(index_commit) when deleting ontology submissions so term and property index cleanup go through the explicit cleanup path.
  • Add a regression test confirming term indexing clears existing term docs by acronym before continuing.

Verification

bundle exec rake test TEST="./test/models/test_ontology_submission.rb" TESTOPTS="--verbose --name=test_index_terms_clears_existing_term_docs_by_acronym"

Use the acronym-scoped term index cleanup when reindexing ontology terms, and use the full ontology index cleanup when deleting a submission. This prevents stale class docs from older submissions from remaining in Solr and appearing in suggest search results.
@mdorf mdorf merged commit 353d706 into develop 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