diff --git a/Classes/Command/NodeIndexQueueCommandController.php b/Classes/Command/NodeIndexQueueCommandController.php index ca0fc92..151ea29 100644 --- a/Classes/Command/NodeIndexQueueCommandController.php +++ b/Classes/Command/NodeIndexQueueCommandController.php @@ -276,12 +276,15 @@ protected function indexWorkspace(string $workspaceName, string $indexPostfix): $this->outputLine('++ Indexing %s workspace', [$workspaceName]); $nodeCounter = 0; $offset = 0; + $lastPOI = null; while (true) { - $iterator = $this->nodeDataRepository->findAllBySiteAndWorkspace($workspaceName, $offset, $this->batchSize); + $iterator = $this->nodeDataRepository->findAllBySiteAndWorkspace($workspaceName, $lastPOI, $this->batchSize); $jobData = []; foreach ($this->nodeDataRepository->iterate($iterator) as $data) { + $lastPOI = $data['persistenceObjectIdentifier']; + $jobData[] = [ 'persistenceObjectIdentifier' => $data['persistenceObjectIdentifier'], 'identifier' => $data['identifier'], diff --git a/Classes/Domain/Repository/NodeDataRepository.php b/Classes/Domain/Repository/NodeDataRepository.php index ddbc6b9..3f5da65 100644 --- a/Classes/Domain/Repository/NodeDataRepository.php +++ b/Classes/Domain/Repository/NodeDataRepository.php @@ -44,24 +44,28 @@ class NodeDataRepository extends Repository /** * @param string $workspaceName - * @param int $firstResult + * @param string $lastPOI * @param int $maxResults * @return IterableResult * @throws \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception */ - public function findAllBySiteAndWorkspace(string $workspaceName, int $firstResult = 0, int $maxResults = 1000): IterableResult + public function findAllBySiteAndWorkspace(string $workspaceName, string $lastPOI=null, int $maxResults = 1000): IterableResult { /** @var QueryBuilder $queryBuilder */ $queryBuilder = $this->entityManager->createQueryBuilder(); $queryBuilder->select('n.Persistence_Object_Identifier persistenceObjectIdentifier, n.identifier identifier, n.dimensionValues dimensions, n.nodeType nodeType, n.path path') ->from(NodeData::class, 'n') ->where('n.workspace = :workspace AND n.removed = :removed AND n.movedTo IS NULL') - ->setFirstResult((integer)$firstResult) ->setMaxResults((integer)$maxResults) ->setParameters([ ':workspace' => $workspaceName, ':removed' => false, - ]); + ]) + ->orderBy('n.Persistence_Object_Identifier'); + + if (!empty($lastPOI)) { + $queryBuilder->andWhere($queryBuilder->expr()->gt('n.Persistence_Object_Identifier', $queryBuilder->expr()->literal($lastPOI))); + } $excludedNodeTypes = array_keys(array_filter($this->nodeTypeIndexingConfiguration->getIndexableConfiguration(), static function($value) { return !$value;