X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/a0fde50c084dfe033187c0a96bd302cfdd9c2443..7d74bf781c3db408d26b200c72fbbb85371f0ed0:/lib/Geocode.php 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; }