This commit is contained in:
2026-05-11 15:23:34 +08:00
parent ed70a140a2
commit 547cbbb4a5
25 changed files with 721 additions and 332 deletions
@@ -17,20 +17,20 @@ class ChunkSearchIndexHandler
$this->index = $index ?? new OpenSearchChunkIndex();
}
public function handle(array $task): void
public function handle(array $task): int
{
if (($task['target_type'] ?? null) !== 'archive') {
return;
return 0;
}
$archiveUid = trim((string) ($task['target_uid'] ?? ''));
if ($archiveUid === '') {
return;
return 0;
}
$documents = $this->chunks->findQueuedDocuments($archiveUid, (int) config('opensearch.bulk.chunk_size', 500));
if ($documents === []) {
return;
return 0;
}
$chunkUids = array_column($documents, 'chunk_uid');
@@ -39,7 +39,7 @@ class ChunkSearchIndexHandler
try {
$documents = $this->validatedDocuments($documents);
if ($documents === []) {
return;
return 0;
}
$chunkUids = array_column($documents, 'chunk_uid');
@@ -53,6 +53,7 @@ class ChunkSearchIndexHandler
$indexedChunkUids = array_values(array_diff($chunkUids, $failedChunkUids));
$this->chunks->markIndexed($indexedChunkUids);
return count($chunkUids);
} catch (Throwable $exception) {
$this->chunks->markFailed($chunkUids, $exception->getMessage(), true);
throw $exception;