Skip to content

Commit

Permalink
Add clearing of different document manager to reindex command (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored Dec 2, 2024
1 parent 5c8226f commit 88f666c
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 88f666c

Please sign in to comment.