Skip to content

Commit

Permalink
Add clearing of different document manager to reindex command
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Dec 2, 2024
1 parent 7b40fb2 commit 8fdd4b2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Command/ReindexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,22 @@ protected function indexDocuments(string $locale, IndexerInterface $indexer, Out
$progressBar = new ProgressBar($output, $count);
$progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
$progressBar->start();
$count = 0;

foreach ($documents as $document) {
$indexer->index($document);
$progressBar->advance();

++$count;

if (0 === ($count % 100)) {
$indexer->flush();
$this->documentManager->clear();
}

if (0 === ($count % 500)) {
\gc_collect_cycles();
}
}

$indexer->flush();
Expand Down

0 comments on commit 8fdd4b2

Please sign in to comment.