X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c5e792def965b0f4dccd42c80e0901a5a8f4d19b..69f30e8e193b5be4b7fc6b504641e6d17fe1827b:/lib/Geocode.php diff --git a/lib/Geocode.php b/lib/Geocode.php index 5343873f..b176701c 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; }