X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/4e478c8af0dff8d7de52ea22e4e0b817135cb28c..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; }