From: Sarah Hoffmann Date: Thu, 3 Jan 2019 20:49:50 +0000 (+0100) Subject: correctly discard partially matching duplicates X-Git-Tag: v3.3.0~45 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/7d74bf781c3db408d26b200c72fbbb85371f0ed0?hp=a0fde50c084dfe033187c0a96bd302cfdd9c2443 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. --- 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; }