Fix: rebuild the search index automatically when it is corrupted, instead of hard-failing (#14180)

This commit is contained in:
Trenton H
2026-09-19 12:53:36 -07:00
committed by GitHub
parent cc25144dbf
commit d5425a893d
2 changed files with 59 additions and 1 deletions
+10 -1
View File
@@ -337,4 +337,13 @@ def open_or_rebuild_index(index_dir: Path | None = None) -> tantivy.Index:
idx = tantivy.Index(build_schema(), path=str(index_dir))
_write_sentinels(index_dir)
return idx
return tantivy.Index.open(str(index_dir))
try:
return tantivy.Index.open(str(index_dir))
except ValueError:
logger.exception(
"Search index is corrupted or incomplete - rebuilding from scratch.",
)
wipe_index(index_dir)
idx = tantivy.Index(build_schema(), path=str(index_dir))
_write_sentinels(index_dir)
return idx