Skip to content

Commit

Permalink
fixed clear all article view documents (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes authored and alexander-schranz committed Apr 5, 2017
1 parent b90fb6f commit bf3d986
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Document/Index/ArticleIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,14 @@ public function clear()
->addQuery(new MatchAllQuery())
->setSize($pageSize);

$count = $repository->count($repository->createSearch()->addQuery(new MatchAllQuery()));
$maxPage = ceil($count / $pageSize);
for ($page = 1; $page <= $maxPage; ++$page) {
$search->setFrom(($page - 1) * $pageSize);
foreach ($repository->execute($search) as $document) {
do {
$result = $repository->execute($search);
foreach ($result as $document) {
$this->manager->remove($document);
}

$this->manager->commit();
}
} while ($result->count() !== 0);

$this->manager->clearCache();
$this->manager->flush();
Expand Down

0 comments on commit bf3d986

Please sign in to comment.