#!/usr/bin/env php ensureExists(); $resetCount = $repository->resetEmbeddedChunksToPending($archiveUid); $archiveCount = 0; $indexedArchives = []; $indexedChunks = 0; while (true) { $archiveUids = $repository->queuePendingArchiveTasks(100); if ($archiveUids === []) { break; } foreach ($archiveUids as $uid) { $handler->handle([ 'task_type' => 'search_index', 'target_type' => 'archive', 'target_uid' => $uid, 'attempt' => 1, ]); $archiveCount++; $indexedArchives[] = $uid; } } $indexedChunksQuery = Db::table('chunks')->where('search_index_status', 3); if ($archiveUid !== null && trim($archiveUid) !== '') { $indexedChunksQuery->where('archive_uid', trim($archiveUid)); } $indexedChunks = (int) $indexedChunksQuery->count(); echo 'OpenSearch reindex completed.' . PHP_EOL; echo 'Index: ' . config('opensearch.indices.chunks', 'proofdb_chunks') . PHP_EOL; echo 'Archive filter: ' . ($archiveUid ?: '(all embedded archives)') . PHP_EOL; echo 'Reset chunks: ' . $resetCount . PHP_EOL; echo 'Indexed archives: ' . $archiveCount . PHP_EOL; echo 'Indexed chunk rows now marked indexed: ' . $indexedChunks . PHP_EOL; if ($indexedArchives !== []) { echo 'Archives: ' . implode(', ', $indexedArchives) . PHP_EOL; } } catch (Throwable $exception) { fwrite(STDERR, $exception::class . ': ' . $exception->getMessage() . PHP_EOL); exit(1); }