fix delete broken documents

This commit is contained in:
team 1
2026-02-18 10:31:24 +01:00
parent 9aa2bbcda4
commit e79ef839d8

View File

@@ -137,14 +137,30 @@ final readonly class IngestFlow
throw new \RuntimeException('Document not found.'); throw new \RuntimeException('Document not found.');
} }
// Chunks entfernen
$this->chunkManager->compactByDocument($documentId); $this->chunkManager->compactByDocument($documentId);
$this->rebuildIndex(false); // Dokument aus DB entfernen
$this->em->remove($document); $this->em->remove($document);
$this->em->flush(); $this->em->flush();
// Prüfen, ob noch INDEXED-Versionen existieren
$indexedCount = $this->em
->getRepository(DocumentVersion::class)
->count([
'ingestStatus' => DocumentVersion::INGEST_INDEXED,
]);
if ($indexedCount === 0) {
// Kein Reindex notwendig
return;
} }
// 4⃣ Reindex nur wenn sinnvoll
$this->rebuildIndex(false);
}
// ========================================================= // =========================================================
// CENTRAL REBUILD // CENTRAL REBUILD
// ========================================================= // =========================================================