From 7d74bf781c3db408d26b200c72fbbb85371f0ed0 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 3 Jan 2019 21:49:50 +0100 Subject: [PATCH] correctly discard partially matching duplicates The same result may be found with different result ranks in the same search loop when housenumber or postcode are part of the name or address. In this case we need to keep the result with the lower result rank. Fixes #1264. --- lib/Geocode.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Geocode.php b/lib/Geocode.php index e2fd7272..8b153d9a 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -758,13 +758,22 @@ class Geocode $oValidTokens->debugTokenByWordIdList() ); - $aResults += $oSearch->query( + $aNewResults = $oSearch->query( $this->oDB, $this->iMinAddressRank, $this->iMaxAddressRank, $this->iLimit ); + // The same result may appear in different rounds, only + // use the one with minimal rank. + foreach ($aNewResults as $iPlace => $oRes) { + if (!isset($aResults[$iPlace]) + || $aResults[$iPlace]->iResultRank > $oRes->iResultRank) { + $aResults[$iPlace] = $oRes; + } + } + if ($iQueryLoop > 20) break; } -- 2.43.2