Skip to content

Commit 8421d33

Browse files
committed
FEATURE: Log a warning if nodes could not have been converted
1 parent bd7069c commit 8421d33

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

Classes/Eel/ElasticSearchQueryBuilder.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ protected function convertHitsToNodes(array $hits): array
859859
{
860860
$nodes = [];
861861
$elasticSearchHitPerNode = [];
862+
$notConvertedNodePaths = [];
862863

863864
/**
864865
* TODO: This code below is not fully correct yet:
@@ -879,17 +880,30 @@ protected function convertHitsToNodes(array $hits): array
879880
if (is_array($nodePath)) {
880881
$nodePath = current($nodePath);
881882
}
883+
882884
$node = $this->elasticSearchClient->getContextNode()->getNode($nodePath);
883-
if ($node instanceof NodeInterface && !isset($nodes[$node->getIdentifier()])) {
884-
$nodes[$node->getIdentifier()] = $node;
885-
$elasticSearchHitPerNode[$node->getIdentifier()] = $hit;
886-
if ($this->limit > 0 && count($nodes) >= $this->limit) {
887-
break;
888-
}
885+
886+
if (!$node instanceof NodeInterface) {
887+
$notConvertedNodePaths[] = $nodePath;
888+
continue;
889+
}
890+
891+
if (isset($nodes[$node->getIdentifier()])) {
892+
continue;
893+
}
894+
895+
$nodes[$node->getIdentifier()] = $node;
896+
$elasticSearchHitPerNode[$node->getIdentifier()] = $hit;
897+
if ($this->limit > 0 && count($nodes) >= $this->limit) {
898+
break;
889899
}
890900
}
891901

892-
$this->logThisQuery && $this->logger->debug('Returned nodes (' . $this->logMessage . '): ' . count($nodes));
902+
$this->logThisQuery && $this->logger->debug(sprintf('[%s] Returned %s nodes.', $this->logMessage, count($nodes)), LogEnvironment::fromMethodName(__METHOD__));
903+
904+
if (!empty($notConvertedNodePaths)) {
905+
$this->logger->warning(sprintf('[%s] Search resulted in %s hits but only %s hits could be converted to nodes. Nodes with paths "%s" could not have been converted.', $this->logMessage, count($hits), count($nodes), implode(', ', $notConvertedNodePaths)), LogEnvironment::fromMethodName(__METHOD__));
906+
}
893907

894908
$this->elasticSearchHitsIndexedByNodeFromLastRequest = $elasticSearchHitPerNode;
895909

0 commit comments

Comments
 (0)