Fix: flag recreated search index for reindex on next startup (#14877)

This commit is contained in:
Trenton H authored and GitHub committed 2026-11-26 09:57:00 -08:00
1 parent b0dea5a07d
commit f775b94cd6
2 files changed
+24 -1

No files matched your search

+6 -1
View File
@@ -387,9 +387,14 @@ def open_or_rebuild_index(index_dir: Path | None = None) -> tantivy.Index:
logger.exception(
"Search index is corrupted or incomplete. A new, empty index was "
"created, but existing documents are not indexed yet. "
"Run 'document_index reindex' to repopulate it.",
"They will be reindexed on the next startup, or run "
"'document_index reindex' to do so now.",
)
wipe_index(index_dir)
idx = tantivy.Index(build_schema(), path=str(index_dir))
_write_sentinels(index_dir)
# The new index is stamped as current but is empty. Flag it so the next
# `document_index reindex --if-needed` repopulates it. Reindexing here
# would block whichever process happened to open the index first.
(index_dir / REBUILD_MARKER).touch()
return idx